Backing up linux .config & apps to move to a new device/distro
Table of Contents
burn it all down… or?
Ahh, a tale born from the first time that I dipped my toes into the weird, wide and wonderful world of distro-hopping. Because sometimes, instead of building it all from scratch again (like so many of us are fond of doing), bringing your old config, notes of a previous home, with you is desirable. Because don’t lie - we won’t get those hours spent tweaking shell configs to look just how we like it back.
In any case - the following (somewhat high-level) overview should get you up and running on a new system/distro fairly quickly, in an environment
Basically, most user settings (from my research - some may be hidden in other corners, but this got me back to a similar place) are stored in `/home/[user-name]/.config/.
So, for me, this was at /home/juni/.config/
. So, simply copy that folder to an external drive or over the network, and paste it in the corresponding place on your new system.
- Copying over .config
-
cd /home/[user]/
- navigate to the user’s directory where the
.config
folder is stored.
- navigate to the user’s directory where the
-
`sudo tar cvzf configs-backup.tgz .config/
- creates a compressed archive (
configs-backup.tgz
) of the.config
folder withtar
, and passingcvzf
as parameters:c
-c
reate a new archivev
- enablev
erbose output, to monitor the progressz
- compress with the gz
ip algorithmf
- specifies the name of the created archivef
ile (in this case,configs-backup.tgz
) Alternatively, you could use a tool likersync
to copy the entire/home/
folder to an external ssd, although this can take a long time depending on its size. I’d recommendrsync
over just copying withcp
, asrsync
copies all files whilst retainingowner/group/other
file permissions.
- creates a compressed archive (
-
If connecting an external SSD to copy to: `sudo fdisk -l
- lists the connected disk drives and their corresponding filesystem location - like `/dev/sda1)
-
`sudo mkdir -p /mnt/externalssd
- creates a folder on your computer’s filesystem to act as a mount point: i.e. a place where you can access files stored on a mounted external SSD.
-
`sudo mount -t exfat /dev/sda1 /mnt/externalssd
- Mounting the SSD (the device we found at
/dev/sda1
) ‘in’ this new folder created in the previous step, allowing all the files on it to appear in/mnt/externalssd
.
- Mounting the SSD (the device we found at
-
You should now be able to navigate there with
cd /mnt/externalssd
and run als
to show the SSD’s existing contents. Then, copy the compressed .config file withcp /home/[user]/configs-backup.tgz /mnt/externalssd
(may require prependingsudo
depending on user permissions) - and you’re done!.
If you opted for rsync
instead above:
sudo rsync -avh --progress /home/[user]/ /mnt/externalssd/home-backup
- a
- preserves file a
ttributes & ensures a mirror copy is created, including permissions, symlinks, etc.
- v
- enable v
erbose output, to monitor the progress
- h
- ensures output is h
uman-readable
- --progress
- displays real-time progress for troubleshooting purposes.
-
Now just unmount the drive with
sudo umount /mnt/externalssd
(or don’t - live on the edge ;), plug it into new machine/distro, and copy the file you created over into/home/[new-user]/
withcp
.Make sure to de-compress the file (if you used
tar
) withtar xvzf configs-backup.tgz
, so it can be read by the system!Then reboot, and your settings should be re-applied! :3
- BONUS: Grabbing a list of installed packages to re-install
Optionally, if you want to grab a list of all packages/apps installed on your current distro to bring over and auto-install on your new one, run the following:
Debian-based distros (e.g. Ubuntu, Kali, etc.):
dpkg --get-selections > installed-packages.txt
- saves a list of all packages to
installed-packages.txt
. Save this on an external SSD or transfer to the new machine via the network. On the New Machine/Distro:
- saves a list of all packages to
sudo apt update
- Navigate to where
installed-packages.txt
is stored (on the local machine), and runsudo dpkg --set-selections < installed-packages.txt
- Run
sudo apt-get dselect-upgrade
The process is similar for distributions using different package managers like yum
, pacman
, or rpm
, the concept is the same but the commands will differ slightly. A little net/manual searching will fix you up :P.
- Related helpful articles:
- https://help.ubuntu.com/community/BackupYourSystem/TAR
- https://askubuntu.com/questions/7809/how-to-back-up-my-entire-system
DISCLAIMER: I would consider this a LEGACY POST of mine, written a long time ago. Please excuse any typos, errors or lapses in memory/judgement - as it was added to the site from the archives, just to put everything in one place. Thankq for your understanding 🙇♀️