Score:1

backup and restore UFW configuration

cn flag

I am using ufw since years and I found that ufw does occasionally save its configuration in /etc/ufw directory. One can find these backups in /etc/ufw/ with backup time added.

after6.rules
after6.rules.20210709_152715
after.init
after.rules
after.rules.20210709_152715
before6.rules
before6.rules.20210709_152715
before.init
before.rules
before.rules.20210709_152715
user6.rules
user6.rules.20210709_152715
user.rules
user.rules.20210709_152715

So my question now is under what condition was this backup made?

Can I trigger such a backup?

Is there a command that will restore such a backup?

Thomas Aichinger avatar
cn flag
iptables-restore and iptables-save are using a different format to save iptables configuration.
Thomas Aichinger avatar
cn flag
I just found out that ufw creates such a backup whenever you issue a ufw reset. But I still dont know if there is a command that will restore such a ufw backup.
Thomas Aichinger avatar
cn flag
man ufw-framework nice description but there is no backup and restore functionality.
Thomas Aichinger avatar
cn flag
I dont want to rename or read anything. I want to restore the files exactly as they are.
Score:0
cn flag

When I did a ufw reset a backup was made

result of command ufw reset. It shows all the files it backed up

In my case only the rule files were backed-up. So if you only have one backup you can do this to restore:

sudo mv /etc/ufw/user.rules{.*,}
sudo mv /etc/ufw/before.rules{.*,}
sudo mv /etc/ufw/after.rules{.*,}
sudo mv /etc/ufw/user6.rules{.*,}
sudo mv /etc/ufw/before6.rules{.*,}
sudo mv /etc/ufw/after6.rules{.*,}

If you've got multiple backups, that won't work, you'd have to replace * with the corresponding date

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.