What commands to use to undo migration steps on ufw

The instructions for migrating MIAB to a new host include:
sudo ufw reset
sudo ufw allow 22
sudo ufw enable

if I perform these commands and do a backup and then find I want to return my old box to operational mode what commands are run to undo the above three commands?

Does a re-run of sudo mailinabox do it? Does a reboot do it?

thanks

sudo ufw reset
sudo ufw limit 22
sudo ufw allow 53
sudo ufw allow 25
sudo ufw allow 465
sudo ufw allow 587
sudo ufw allow 993
sudo ufw allow 995
sudo ufw allow 4190
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

Here is what is running on my box:

root@mail:~# sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     LIMIT       Anywhere
53                         ALLOW       Anywhere
25/tcp                     ALLOW       Anywhere
465/tcp                    ALLOW       Anywhere
587/tcp                    ALLOW       Anywhere
993/tcp                    ALLOW       Anywhere
995/tcp                    ALLOW       Anywhere
4190/tcp                   ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443/tcp                    ALLOW       Anywhere
22/tcp (v6)                LIMIT       Anywhere (v6)
53 (v6)                    ALLOW       Anywhere (v6)
25/tcp (v6)                ALLOW       Anywhere (v6)
465/tcp (v6)               ALLOW       Anywhere (v6)
587/tcp (v6)               ALLOW       Anywhere (v6)
993/tcp (v6)               ALLOW       Anywhere (v6)
995/tcp (v6)               ALLOW       Anywhere (v6)
4190/tcp (v6)              ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443/tcp (v6)               ALLOW       Anywhere (v6)
Usage: ufw COMMAND

Commands:
 enable                          enables the firewall
 disable                         disables the firewall
 default ARG                     set default policy
 logging LEVEL                   set logging to LEVEL
 allow ARGS                      add allow rule
 deny ARGS                       add deny rule
 reject ARGS                     add reject rule
 limit ARGS                      add limit rule
 delete RULE|NUM                 delete RULE
 insert NUM RULE                 insert RULE at NUM
 route RULE                      add route RULE
 route delete RULE|NUM           delete route RULE
 route insert NUM RULE           insert route RULE at NUM
 reload                          reload firewall
 reset                           reset firewall
 status                          show firewall status
 status numbered                 show firewall status as numbered list of RULES
 status verbose                  show verbose firewall status
 show ARG                        show firewall report
 version                         display version information

Application profile commands:
 app list                        list application profiles
 app info PROFILE                show information on PROFILE
 app update PROFILE              update PROFILE
 app default ARG                 set default application policy

Alternatively you could probably “repair your setup” by running the installer again on your old box.

curl -s https://mailinabox.email/setup.sh | sudo bash

delete rules by first listing them:

sudo ufw status numbered

then delete them like this:

sudo ufw delete {rule number from previous command}

I included protocols so as to restore the exact ufw status I had prior to the reset:

 ufw limit 22/tcp
 ufw allow 53
 ufw allow 25/tcp
 ufw allow 465/tcp
 ufw allow 587/tcp
 ufw allow 993/tcp
 ufw allow 995/tcp
 ufw allow 4190/tcp
 ufw allow 80/tcp
 ufw allow 443/tcp

I tried the sudo mailinabox command on the host which also restored all the firewall settings.

thanks for the info from all!

thanks for the awesome information.