When I have to do a reinstall, sometimes I have to install from scratch – doing a clean install is just sometimes necessary. My configurations are priceless to me and after my reinstall I restore them from a backup copy. Here’s how I quickly add my configurations to an include file and back them up on a regular basis done with a basic script.
Basic tar Command
A good number of GUI programs can do this (you can read about the ones I’ve looked at here), but they seem to make the process more complicated, so I went back to tar and created a script. And it makes adding and subtracing files easy. For those new to tar the basic archive command is:
tar -c --xz -f <backupname>.tar.xz /folder/file /folder ...
Include/Exclude Files
By putting the archive command in a bash script it can be used later. Files and folders can be appended to the command in the script but for multiple files consider using include and exclude files:
#!/bin/bash tar --files-from=include.txt --exclude-from=exclude.txt -c --xz -f backupname.tar.xz
Include/exclude files contain the path on a line of what or what-not to backup. The include file should list the full path and cannot use regexps but the exclude fine can:
/home/*/.local/share/Trash/files /home/*/.Trash
Add Paths to Include/Exclude Quickly
To add paths to the include/exclude files readlink can be used. Adding to the include and exclude files can be done like this (using the script below):
$ bckcfg i /etc/rc.conf Added "/etc/rc.conf" to bckcfg include file.
$ bckcfg e ~/.thumbnails/ * "bckcfg" doesn't check if patch is correct because the exclude file can contain regexps. Be sure the path is correct (e.g. '/mnt/win/*') Add "/home/todd/.thumbnails/" to bckcfg exclude file? (y/n): y Added "/home/todd/.thumbnails/" to bckcfg exclude file.
Creating notes of backups can be done by:
$ bckcfg n Added font config $:cat bckcfg-not.txt | tail -n 2 20xx-08-14-02:52:23 PM: Added dhcp cacher config 20xx-08-14-02:52:33 PM: Added font config
The Backup Script
To backup do:
bckcfg c
The script names the backup by several definable variables and removes old backups if desired.
Consider putting it in a cron job to get regular backups.
o/

Very good article!
Thank you.