Automated Timestamped Nightly TAR Backups
Create a new file (backup.sh) with your text editor and make it executable (chmod +x backup.sh)
Script contents:
#!/bin/zsh
location=/mnt/D/Dropbox/Linux/backups
includes=/mnt/D/Dropbox/Linux/backups/includes
excludes=/mnt/D/Dropbox/Linux/backups/excludes
date=$(date +%d.%m.%y--%I.%M%p)
file="$location/backup-$date.tar"
tar -cvpf $file --files-from=$includes --exclude-from=$excludes
Include file should contain paths of stuff you want backed up:
Example:
/home/pentago/.config/sublime-text-3/
/etc/pacman.conf
/etc/makepkg.conf
Exclude file should contain paths to junk you don't want in your tarball and whose parent is already included in includes file:
Example:
/home/pentago/.config/sublime-text-3/Cache
/home/pentago/.config/sublime-text-3/Backup
/home/pentago/.config/sublime-text-3/Index
Backups don't have a purpose if they're not backed up off site (Dropbox for instance) and if they're not automated (via cronjob):
$ crontab -l
0 0 * * * sh /mnt/D/Dropbox/Linux/backups/backup.sh > /dev/null 2>&1
Outcome:
Do not forget to occasionally update includes/excludes files to backup/remove new stuff you got in the meantime.
Written by Goran
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Script
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#