Skip to content

Instantly share code, notes, and snippets.

@spring-raining
Created June 22, 2018 13:09
Show Gist options
  • Select an option

  • Save spring-raining/a29c1d7b577a03e8cb973cb98fd66211 to your computer and use it in GitHub Desktop.

Select an option

Save spring-raining/a29c1d7b577a03e8cb973cb98fd66211 to your computer and use it in GitHub Desktop.
bkup
#!/bin/bash
# full system backup
# Backup destination
backdest=/opt/backup
# Labels for backup name
#PC=${HOSTNAME}
pc=pavilion
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/<user>/.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment