Skip to content

Instantly share code, notes, and snippets.

@theKAKAN
Created January 20, 2021 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theKAKAN/b1e37bba2e8b58b464dff46c9d10e27c to your computer and use it in GitHub Desktop.
Save theKAKAN/b1e37bba2e8b58b464dff46c9d10e27c to your computer and use it in GitHub Desktop.
Backup all my important files to where-ever I choose
# Where should we store the backups?
BACKUP_DIR="/mnt/backup_drive/$(hostname)/$(date -u +\"%Y-%m-%d\")"
# Backup /etc
sudo rsync -avzP /etc $BACKUP_DIR
# Backup /var excluding many heavy files
sudo rsync -avzP --exclude 'cache' \
--exclude 'lib/flatpak' \
--exclude 'lib/dnf' --exclude 'lib/dpkg' \
--exlclude 'lib/libvirt' \
--exclude 'lock' --exclude 'run' \
/var $BACKUP_DIR
# Backup /opt and /srv
sudo rsync -avzP /opt $BACKUP_DIR
sudo rsync -avzP /srv $BACKUP_DIR
# Back up /usr/local since it contains mostly user-installed applications
sudo rsync -avzP /usr/local $BACKUP_DIR/usr
# I should backup /root and /home
sudo rsync -avzP /root $BACKUP_DIR
# This will backup every user's /home, so be sure to edit it if you've just vmail boxes or something only...
sudo rsync -avzP /home $BACKUP_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment