1. Home
  2. Linux

How to back up your Linux PC’s icon themes

Do you install icon themes on your Linux PC to spice it up and make it look nice? Do you want to create a backup of these icon files in case of data loss? If so, we can help! Follow along in this guide as we show you how to back up your Linux PC’s icon themes.

Backing up icons stored in ~/.icons

If you install custom icon themes on your Linux PC, in single-user mode, all of these icon files exist in the ~/.icons directory in your home folder. To back up these icon files, you will need to make a complete backup of this directory. In this section of the guide, we will go over how you can quickly create a backup of this directory.

Creating a backup of icon files in the ~/.icons folder on Linux is best done with a TarGZ archive. The fastest way to create a TarGZ archive on Linux is through the terminal. Launch a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. When the terminal window is open, make use of the mkdir command to create a new directory with the name of “icon-backup.”

mkdir -p ~/icon-backup

After making this new folder, use the CD command to move the terminal session into the ~/.icons directory, where all of the single-user icon files are installed.

cd ~/.icons

Inside of the ~/.icons folder, make use of the cp command to make a complete copy of this folder, and place everything into the newly created “icon-backup” directory that you created earlier. Be sure to use the -r command-line switch, as it will allow you to copy recursively.

cp -r * ~/icon-backup

After running this command, all single-user icon files in your home directory will begin copying to the newly created backup folder. This copy command will take a couple of minutes to complete. When the process is complete, you will have all of the single-user icon files on your computer placed into the ~/icon-backup directory.

Once all files are moved into the backup folder, the compression can begin. Using the CD command, move from the ~/.icons directory and into the home folder (~). Then, make use of the tar command to create a compressed archive of the ~/icon-backup directory.

cd ~/

tar -czvf icon-backup.tar.gz ~/icon-backup

The compression will take a few to complete, so be patient. When the process is complete, you will have a new backup archive with the name of icon-backup.tar.gz in your home directory. From here, you can take this backup file and upload it to Dropbox, Google Drive, a home server, or elsewhere.

Restoring the backup

To restore the backup, place icon-backup.tar.gz into your home directory using the Linux file manager. After that, make use of the tar xvf command below to decompress the backup and restore it to its original location in the ~/.icons folder.

tar xvf icon-backup.tar.gz -C ~/.icons/ --strip-components=3

Backing up icons stored in /usr/share/icons/

The other way of installing icon themes on Linux besides single-user mode is the system-wide mode. This method of installation is popular with those who want icon theme files accessible to all users on the system, rather than just one user. If you want to back up icon files in system-wide mode, you must compress all of the contents of /usr/share/icons/.

To start the backup process in system-wide mode, you must create a new directory. This new directory will hold a copy of all of the theme files, which will then be compressed, much like in the single-user backup instructions. To create a new folder, make use of the following mkdir command below.

mkdir -p ~/system-icon-backup

After creating the new “system-icon-backup” directory in your home folder (~), use the sudo -s command to elevate the terminal session to root access, without leaving your current directory.

sudo -s

Once you’ve gotten root access, make a complete copy of all of the icon files in the /usr/share/icons/ directory using the cp command. Be sure to use the -r command-line switch, as it is important and will allow you to make recursive copies.

Note: you must change USERNAME to your username on your Linux PC. For example, if my username is “derrik,” the command willd be /home/derrik/system-icon-backup.

cd /usr/share/icons/
cp -r * /usr/share/icons/ /home/USERNAME/system-icon-backup

When everything is done copying, exit root mode with the exit command. By exiting root mode, you will return to your normal user account.

exit

Once you’re back on your normal user account, create a TarGZ archive of your icon file backup using the tar command.

tar -czvf system-icon-backup.tar.gz ~/system-icon-backup

When the compression process is complete, feel free to take system-icon-backup.tar.gz and upload it to Dropbox, Google Drive, a home server, or elsewhere.

Restoring the backup

To restore the system-wide icon backup, start by placing system-icon-backup.tar.gz in the home directory using the Linux file manager. After that, use the sudo -s command to elevate your command-line session to root access.

sudo -s

One the terminal session has root access, use the tar command below to decompress the backup to the original location.

tar xvf system-icon-backup.tar.gz -C /usr/share/icons/ --strip-components=3

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.