Skip to content

Instantly share code, notes, and snippets.

@lukas-h
Created May 1, 2019 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukas-h/80dfa0177c44933ebe73d3a2b534c3a1 to your computer and use it in GitHub Desktop.
Save lukas-h/80dfa0177c44933ebe73d3a2b534c3a1 to your computer and use it in GitHub Desktop.
Backup your linux system harddrive
#!/bin/sh
# Written by Lukas Himsel <lukas.himsel@web.de>
#
# -> backup your complete linux system <-
#
# Variables:
# BACKUP_DEVICE is the *mounted* harddrive for the backup
# BACKUP_DATE is the actual date and it's used to create a folder
# with the actual date
#
# Execute:
# You can execute it as normal user with superuser rights (admin).
#
# Dependencies:
# Make sure you have installed `rsync`.
# If not execute `apt-get install rsync` (on Debian, Ubuntu)
# You also need the program `date`, integrated in the Coreutils...
#
# Resources:
# See https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync
# for more infos
#
# variables
BACKUP_DEVICE=/media/$USER/backup # please change the path so, that it points to your backup drive
BACKUP_DATE=`date "+%y.%m.%d-%H:%M"`
# make directory for snapshot
sudo mkdir $BACKUP_DEVICE/$BACKUP_DATE
# execute rsync to create the backup
cd
sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found", "/home/*/.thumbnails/*", "/home/*/.cache/mozilla/*", "/home/*/.cache/chromium/*", "/home/*/.local/share/Trash/*"} / $BACKUP_DEVICE/$BACKUP_DATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment