#! /bin/bash # Copy borgwrapper to bin directory echo "Installing borgwrapper in: /usr/local/bin/" cp -i ./src/borgwrapper /usr/local/bin/borgwrapper chown root. /usr/local/bin/borgwrapper chmod 750 /usr/local/bin/borgwrapper # Make borgwrapper config directory and move config file echo "Making directory: /etc/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 echo "Copying config to: /etc/borgwrapper/config" cp -i ./config /etc/borgwrapper/config chown root. /etc/borgwrapper/config chmod 600 /etc/borgwrapper/config # Setup systemd echo "Setting up systemd" echo "Copying systemd timer and service unit files to: /etc/systemd/system/" cp ./systemd/*.{timer,service} /etc/systemd/system/ echo "Enabling and starting backup and verify systemd timer units" for config_file in /etc/borgwrapper/* do config_file=$(basename ${config_file}) systemctl enable borgwrapper-backup@"${config_file}".timer systemctl enable borgwrapper-verify@"${config_file}".timer systemctl start borgwrapper-backup@"${config_file}".timer systemctl start borgwrapper-verify@"${config_file}".timer done # Setup logrotate echo "Setting up logrotate for borgwrapper log files" echo "Creating directory: /var/log/borgwrapper/" if [ ! -d /var/log/borgwrapper ]; then mkdir /var/log/borgwrapper fi echo "Creating logrotate file: /etc/logrotate.d/borgwrapper" ( cat < /etc/logrotate.d/borgwrapper # Done. Display some instructions. echo echo "Please edit \"/etc/borgwrapper/config\" to make changes to configuration." echo "You may have multiple configuration files. Please read documentation." echo echo "Read \"README.md\" for more information." echo echo "Logs will be stored in \"/var/log/borgwrapper/*\"" echo