Skip to content

Instantly share code, notes, and snippets.

@mickours
Last active December 15, 2015 05:09
Show Gist options
  • Save mickours/5207012 to your computer and use it in GitHub Desktop.
Save mickours/5207012 to your computer and use it in GitHub Desktop.
Arch linux whole system backup script
#!/bin/bash
if [ $# -lt 1 ]; then
echo "No destination defined. Usage: $0 destination" >&2
exit 1
elif [ $# -gt 1 ]; then
echo "Too many arguments. Usage: $0 destination" >&2
exit 1
elif [ "$(whoami)" != "root" ]; then
echo "ERROR: You must be root to run this script.
Try:
sudo $0 $1"
exit 1
fi
cat > "$1/exclude.txt" << EOF
/dev/*
/proc/*
/sys/*
/tmp/*
/run/*
/mnt/*
/media/*
/data
/var/log
/var/tmp
/lost+found
/var/lib/pacman/sync/*
/home/*/.gvfs
/home/*/.thumbnails/*
/home/*/.mozilla/firefox/*.default/Cache/*
/home/*/.cache/*
/home/*/.local/share/Trash/*
EOF
START=$(date +%s)
rsync -aAXv --delete-after --delete-excluded /* $1 --exclude-from "$1/exclude.txt" 2>&1 | bzip2 -9 > "$1/last_backup.log"
FINISH=$(date +%s)
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"
### END ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment