Looking to build an "exit" script so I can reconfigure my system quick

Hello,

Through the ages I have created a very basic "script" that aims at dumping all of my important files over to my NAS so I can reinstall my system using my old configs in the most effortless way:

Here is my current list of files/folders that have been tagged as useful to backup/restore:

/etc/fstab
/etc/apt/sources.list.d/
/etc/apt/sources.list
/etc/sysctl.conf

~/.config/
~/.ssh/
~/{Documents,Pictures,Music,Videos}
~/.mozilla
~/.zshrc
~/.local/

/opt/

I wanted to know if anybody had ever done such a script(pretty sure that I ain't the first person with that kind of need) and/or if somebody had a flash of inspiration in terms of which other(s) file(s) that it would be wise for me to add to that list?

Putting things into perspective I will be testing this out when wiping 19.10 and installing 20.04 on my main system.

Thanks in advance,

There could be a tinsy winsy problem with restoring this one - depending on how your configuration references disks (UUID or /dev/sdXY)... If you format them, these IDs may become invalid.

Also watch out - this points to the Ubuntu archives for a release - so it would be okay for the same version (19.10), but if restoring a freshly configured 20.04 install, you'll want to skip this or correct the codenames.

sources.list.d would be OK, since that's usually PPAs or external sources, but might need re-pointing to the right codename (discofocal)


While my backup script is more "tar the whole filesystem" and "rsync the data partitions" , it sounds like a pretty simple script for you to rsync (or via a mountpoint with FUSE) to/from the NAS. at your command.

Though it would be cleaner to perform restores via the console (TTY) since some GUI applications may still be running when you restore the file, so it risks a 'fresh' config from memory overwriting a config just restored.

  • Audacity, GIMP, Wine, Steam, Thunderbird are a few that store their configs in the root of the home directory. Watch out if any of your apps do too!
  • If you do any signing/encryption stuff, then .gnupg is an important one to keep.

There could be more system-level files to keep/restore, like:

  • Hostname / Hosts
  • Localization / Keyboard Layouts
  • Wi-Fi Passwords / Network Configuration

but I'm afraid I don't know where all these files are - they'll be somewhere!

You are totally right. My need for /etc/fstab is for the NFS mounts.

I have also duly noted your other points, thanks a lot for your much appreciated feedbacks!

One thing to add from my end is a "dpkg -l > ~/Documents/installed.txt" dump. Speaking of which, there wouldn't exist some sort of "apt install history" that one could simply replay, would it?

1 Like

Apt does track "explicitly installed" packages. Take a look here:

Once you've got a text file list of just package names, then it would be a matter of:

sudo apt install $(cat packages.txt)

Just a thought, but there's snap packages to consider, if you use them.

1 Like