archboot/usr/bin/archboot-rsync-backup.sh

31 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
#
# copy-mointpoint.sh - copy recursivly a mountpoint using tar
# by Tobias Powalowski <tpowa@archlinux.org>
# usage(exitvalue)
# outputs a usage message and exits with value
_APPNAME=$(basename "${0}")
_usage()
{
2023-02-07 20:19:31 +01:00
echo -e "\e[1mWelcome to \e[36mARCHBOOT\e[m\e[1m - RSYNC BACKUP:\e[m"
echo -e "\e[1m-----------------------------------\e[m"
echo -e "- Copy \e[1mbackupdir\e[m to \e[1mbackupdestination\e[m using rsync."
echo -e "- For system backup, start with \e[1mfull\e[m mounted system and then invoke this script"
echo -e " with system's root directory as \e[1mbackupdir\e[m."
echo -e "- \e[1mexcluded\e[m directories are \e[1m/dev /tmp /proc /sys /run /mnt /media /lost+found\e[m"
echo -e "- \e[1m--numeric-ids\e[m option is invoked to \e[1mpreserve\e[m users"
echo ""
2023-02-07 20:19:31 +01:00
echo -e "usage: \e[1m${_APPNAME} <backupdir> <backupdestination>\e[m"
2022-01-21 11:31:10 +01:00
exit "$1"
}
##################################################
if [ $# -ne 2 ]; then
_usage 1
fi
_BACKUPDESTINATION="${2}"
_BACKUPDIR="${1}"
rsync -aAXv --numeric-ids \
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
2023-01-09 21:34:59 +01:00
"${_BACKUPDIR}" "${_BACKUPDESTINATION}"