diff --git a/config b/config new file mode 100644 index 0000000..e0135f1 --- /dev/null +++ b/config @@ -0,0 +1,79 @@ +###################################################################### +## SET THE FOLLOWING TO "TRUE" WHEN YOU HAVE CONFIGURED THIS FILE #### +###################################################################### +CONFIGURED="FALSE" + +############################# + +if [ "${CONFIGURED}" != "TRUE" ]; then + echo "Config file has not been set up." + exit 1 +fi + +# Beginning of configuration: +############################# + +#BORG="/usr/bin/borg" + +SYSTEM_NAME="ths" +BORG_REPO="bryan@172.16.1.83:/srv/borg/${SYSTEM_NAME}" + +# If using a non-standard SSH port ssh:// have to be specified (per borg v1.0.9) +#BORG_REPO="ssh://@:/srv/borg/${SYSTEM_NAME}" +BORG_PASSPHRASE="uD6Db2MrhxdCoKmD4gpW" + +PACKAGE_LIST_DIRECTORY="/srv/dumps/" +MYSQL_DUMP_DIRECTORY="/srv/dumps/" +MONGODB_DUMP_DIRECTORY="/srv/dumps/" + +PATHS=( + "/etc" + "/home" + "/root" + "/srv" + "/usr/local" + "/var/spool/cron/crontabs" + "/mnt" +) +EXCLUDES=( + "sh:/home/**/.cache" + "/root/.cache" + "*.pyc" +) +KEEP_HOURLY=0 +KEEP_DAILY=31 +KEEP_WEEKLY=0 +KEEP_MONTHLY=12 +KEEP_YEARLY=5 + +# Limit bandwith used when backing up to SSH repositories. Requires the utility `pv`. +# The unit is bytes per second. 0 means no limit. The numeric part must be an integer value. +# You can use K, M, G or T binary prefixes (power of 1024), e.g., 5M = 5MiB/s = 5242880 bytes/s. +#BWLIMIT=0 + +# Location of borgwrapper lock files +#LOCKDIR="/run/lock/borgwrapper" + +# You can add args, such as a custom identity key file, to ssh here +#BORG_RSH="ssh" + +# Optional arguments to the different borg commands. +# The current default values are listed. Modify if needed. +#BORG_CREATE_ARGS=( +# --info +# --stats +# --list +# --filter AME +# --compression lz4 +#) +#BORG_PRUNE_ARGS=( +# --info +# --stats +# --list +#) +#BORG_CHECK_ARGS=( +# --info +#) +#BORG_INIT_ARGS=( +# --encryption repokey-blake2 +#) diff --git a/config.example b/config.example new file mode 100644 index 0000000..751b08a --- /dev/null +++ b/config.example @@ -0,0 +1,76 @@ +###################################################################### +## SET THE FOLLOWING TO "TRUE" WHEN YOU HAVE CONFIGURED THIS FILE #### +###################################################################### +CONFIGURED="FALSE" + +if [ "${CONFIGURED}" != "TRUE" ]; then + echo "Config file has not been set up." + exit 1 +fi + +# Beginning of configuration: +############################# + +#BORG="/usr/bin/borg" + +SYSTEM_NAME="name-of-computer" +BORG_REPO="@:/srv/borg/${SYSTEM_NAME}" + +# If using a non-standard SSH port ssh:// have to be specified (per borg v1.0.9) +#BORG_REPO="ssh://@:/srv/borg/${SYSTEM_NAME}" +BORG_PASSPHRASE="longandcomplexpassphrase" + +PACKAGE_LIST_DIRECTORY="/srv/dumps/" +MYSQL_DUMP_DIRECTORY="/srv/dumps/" +MONGODB_DUMP_DIRECTORY="/srv/dumps/" + +PATHS=( + "/etc" + "/home" + "/root" + "/srv" + "/usr/local" + "/var/spool/cron/crontabs" +) +EXCLUDES=( + "sh:/home/**/.cache" + "/root/.cache" + "*.pyc" +) +KEEP_HOURLY=0 +KEEP_DAILY=31 +KEEP_WEEKLY=0 +KEEP_MONTHLY=24 +KEEP_YEARLY=5 + +# Limit bandwith used when backing up to SSH repositories. Requires the utility `pv`. +# The unit is bytes per second. 0 means no limit. The numeric part must be an integer value. +# You can use K, M, G or T binary prefixes (power of 1024), e.g., 5M = 5MiB/s = 5242880 bytes/s. +#BWLIMIT=0 + +# Location of borgwrapper lock files +#LOCKDIR="/run/lock/borgwrapper" + +# You can add args, such as a custom identity key file, to ssh here +#BORG_RSH="ssh" + +# Optional arguments to the different borg commands. +# The current default values are listed. Modify if needed. +#BORG_CREATE_ARGS=( +# --info +# --stats +# --list +# --filter AME +# --compression lz4 +#) +#BORG_PRUNE_ARGS=( +# --info +# --stats +# --list +#) +#BORG_CHECK_ARGS=( +# --info +#) +#BORG_INIT_ARGS=( +# --encryption repokey-blake2 +#) diff --git a/install b/install new file mode 100755 index 0000000..7b9bfa5 --- /dev/null +++ b/install @@ -0,0 +1,35 @@ +#! /bin/bash + +cp -i ./src/borgwrapper /usr/local/bin/borgwrapper +chown root. /usr/local/bin/borgwrapper +chmod 750 /usr/local/bin/borgwrapper + +if [ ! -d /etc/borgwrapper/ ]; then + mkdir /etc/borgwrapper +fi + +if [ ! -e ./config ]; then + echo "Please rename \"config.example\" to \"config\"" + echo "And make sure to update with your settings before running \"install\" again!" + exit 1 +fi + +cp -i ./config /etc/borgwrapper/config +chown root. /etc/borgwrapper/config +chmod 600 /etc/borgwrapper/config + +cp ./systemd/*.{timer,service} /etc/systemd/system/ + +for config_file in /etc/borgwrapper/* +do + systemctl enable borgwrapper-backup@"${config_file}".timer + systemctl enable borgwrapper-verify@"${config_file}".timer + + systemctl start borgwrapper-backup@"${config_file}".timer + systemctl start borgwrapper-verigy@"${config_file}".timer +done + +echo +echo "Please edit \"/etc/borgwrapper/config\" to make changes to configuration." +echo "Read \"README.md\" for more information." +echo