From: Andrew Lorimer Date: Sun, 8 Nov 2020 12:08:27 +0000 (+1100) Subject: add tar backup X-Git-Url: https://git.lorimer.id.au/scripts.git/diff_plain/45c257a1f564289e5c188d4d3b9b94075690a771 add tar backup --- diff --git a/tar-backup.sh b/tar-backup.sh new file mode 100755 index 0000000..43f5741 --- /dev/null +++ b/tar-backup.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# full system backup +# taken from Arch Wiki: +# https://wiki.archlinux.org/index.php/Full_system_backup_with_tar + +# Backup destination +backdest=/backup + +# Labels for backup name +#PC=${HOSTNAME} +pc=ruslan +distro=arch +type=full +date=$(date "+%F") +backupfile="$backdest/$distro-$type-$date.tar.gz" + +# Exclude file location +prog=${0##*/} # Program name from filename +excdir="/home//.bin/root/backup" +exclude_file="$excdir/$prog-exc.txt" + +# Check if chrooted prompt. +echo -n "First chroot from a LiveCD. Are you ready to backup? (y/n): " +read executeback + +# Check if exclude file exists +if [ ! -f $exclude_file ]; then + echo -n "No exclude file exists, continue? (y/n): " + read continue + if [ $continue == "n" ]; then exit; fi +fi + +if [ $executeback = "y" ]; then + # -p and --xattrs store all permissions and extended attributes. + # Without both of these, many programs will stop working! + # It is safe to remove the verbose (-v) flag. If you are using a + # slow terminal, this can greatly speed up the backup process. + tar --exclude-from=$exclude_file --xattrs -czpvf $backupfile / +fi +