Backup Your Webbrowsers' Configs In A Quick Way

Hello there.

I’d like to post this tip for newbies. After having installed umpty linux distros on various computers, some things always get to be done repeatedly, if we have no configuration backups handy. This includes long, sometimes tedious configurations, such as bookmarks, settings, browser extensions, and so on. Therefore, here’s a quick and simple solution to this, using rsync to backup special folders inside one’s home-folder. - Rsync appears to be the fastest way to do any backups in linux via a simple shell-script, afaict.

If you have multiple email-accounts, don’t forget to include your .thunderbird - folder. Customize below code example according to your own needs.

The example is quite self-explanatory, and some further hints are given below.

First, the script-code:

#!/bin/bash
TIME=`date +%b-%d-%y` 
FILENAME=backup-$TIME.tar.gz 
SRCDIR1="/home/MyUsername/.config/chromium/"
SRCDIR2="/home/MyUsername/.mozilla/firefox/"
SRCDIR3="/home/MyUsername/tor-browser_en-US/"
SRCDIR4="/home/MyUsername/.librewolf"
DESTDIR="/Path-to/MyDrive-Folder/"
cd $DESTDIR && tar -cvpzf $FILENAME -C / $SRCDIR1  $SRCDIR2 $SRCDIR3 $SRCDIR4
find /Path-to/MyDrive-Folder/* -mtime +14 -type f -delete

The last line of the script simply means this:
Find all files inside the destination directory and delete files older than 14 days.

Replace username and destination folder in the above code-example:
“SRCDIR1” to “SRCDIR-X” →
Replace MyUsername with your actual username.
“DESTDIR” →
Replace /Path-to/MyDrive-Folder/ with actual path to destination-drive/folder twice: Don’t forget the script’s last line, starting with the find-command.

Next, save it all to a text-file.
Example name for script: “backup.sh”. Save inside your home-folder.

Make the script executable:
chmod +x backup.sh

Run it from terminal:
./backup.sh

The script can also be executed regularly as a cron-job, according to one’s liking.
See: https://wiki.archlinux.org/title/cron

2 Likes

You start off at Trust Level 0 (TL0) and as the community gets to know you, your activities give you more priveleges. Keep interacting and you will get there :smiley: https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/

btw, welcome to the :enos: forums @ivanhoe

1 Like

Thanks! :grinning:

1 Like

Maybe introduce yourself in the Lounge and read the guidelines etc, that goes toward increasing your TL. :wink:

1 Like

Thank you again. Will do!
:grinning:

1 Like

Nice, although using

  1. A dedicated “dotfiles” handler utility, or
  2. A dedicated backup utility

would mean you don’t need to reinvent the wheel.

Having a backup routine is v. important, and then you can just restore whatever files you want from the backup whenever and wherever needed.

1 Like

Why not just back up your entire home folder with deja-dup You can always restore the browser config files.

1 Like