1. Home
  2. Linux

How to back up your Linux PC’s GTK themes

We cover how to install quite a lot of GTK themes here on Addictivetips. Why? GTK themes let Linux users take control of their Linux systems and add a level of customization that other operating systems do not offer. Many Linux fans are itching to know how to install the coolest themes.

That said, we’ve never gone into how to create a backup of these themes. So, if you’re worried about losing your GTK theme files due to data loss, or worse, we’ve got you covered. Here’s how to back up your Linux PC’s GTK themes!

Backing up themes stored in ~/.themes

If you install a lot of GTK themes in “single-user” mode, the majority of the GTK themes you want to back up will be located in the ~/.themes folder. In this section of the guide, we’ll show you how to create a backup of these themes.

To start the process, open up a terminal window. A terminal window is necessary for the backup, as it is the fastest and best way to create a TarGZ backup of many files. Launch a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard.

Once the terminal window is open on the Linux desktop, use the mkdir command to create a new folder in your home directory by the name of “theme-backup”. We need to create this folder, as we will be copying all existing themes in the ~/.themes directory to it for backup purposes.

mkdir -p ~/theme-backup

After creating the new folder in your home directory, make use of the cp command along with the -r switch to create a complete copy of all of the GTK themes installed on your computer in the ~/.themes folder.

cd ~/.themes

cp -r * ~/theme-backup

With all of the theme files copied into the new folder, make use of the tar command to compress the folder into a TarGZ archive. Compressing this folder will make it much easier to upload the backup to an online service such as Dropbox, or Google Drive or a home server as there won’t be hundreds of loose files to deal with.

cd ~/

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

Let the backup run it’s course. It will take a little while to complete, especially if you have a lot of theme files to compress. When the process is complete, you will have made a backup of all of the GTK theme files in the ~/.themes folder on your Linux PC.

To restore these themes to their original location, do the following.

Step 1: Place theme-backup.tar.gz in the home directory.

Step 2: Extract the contents of the directory to the original location.

tar xvf theme-backup.tar.gz -C ~/.themes/ --strip-components=3

Backing up themes stores in /usr/share/themes/

If you install a lot of GTK themes on your Linux PC, but you only do it in system-wide mode, you will need to create a backup of all of the theme files in the /usr/share/themes/ directory. To start the backup process, launch a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, use the mkdir command to create a new folder with the name of “system-wide-theme-backup”.

mkdir -p ~/system-wide-theme-backup

Now that the new folder has been created and you’re in your home directory, the backup process can begin. Using the cp command along with the -r switch, copy all of the files from the /usr/share/themes/ directory and place them into the newly created folder.

cd /usr/share/themes/

cp -r * ~/system-wide-theme-backup/

Allow all of the theme files to copy to the backup folder inside of your home directory. It may take a few minutes to finish up copying, especially if you have a lot of theme files to move around. Once the copying process is complete, use the CD command and exit the /usr/share/themes/ directory, as it’s no longer necessary to be there with the terminal.

cd ~/

Once outside of the /usr/share/themes/ directory and inside of the home directory, you’ll be able to compress the backup into a TarGZ archive. Compressing the theme files into a TarGZ is critical, as it will make uploading your GTK theme backups to Dropbox, Google Drive, or a home server much quicker and easier.

tar -czvf system-wide-theme-backup.tar.gz ~/system-wide-theme-backup

To restore the backup of the theme files, place system-wide-theme-backup.tar.gz archive file into the home directory and follow the step-by-step instructions below.

Step 1: Launch a terminal window and use the sudo -s command to access root mode without leaving your home folder.

sudo -s

Step 2: Decompress the contents of the backup TarGZ file to /usr/share/themes/.

tar xvf system-wide-theme-backup.tar.gz -C /usr/share/themes/ --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.