From 45c257a1f564289e5c188d4d3b9b94075690a771 Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Sun, 8 Nov 2020 23:08:27 +1100 Subject: [PATCH] add tar backup --- tar-backup.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tar-backup.sh 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 + -- 2.43.2