borgwrapper/install

63 lines
1.5 KiB
Bash
Executable File

#! /bin/bash
# Copy borgwrapper to bin directory
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
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
# Setup systemd
cp ./systemd/*.{timer,service} /etc/systemd/system/
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
if [ ! -d /var/log/borgwrapper ]; then
mkdir /var/log/borgwrapper
fi
(
cat <<EOF
/var/log/borgwrapper/borgwrapper.log {
daily
rotate 5
missingok
nocompress
create
}
EOF
) > /etc/logrotate/logrotate.d/borgwrapper
# Done. Display some instructions.
echo
echo "Please edit \"/etc/borgwrapper/config\" to make changes to configuration."
echo
echo "Read \"README.md\" for more information."
echo
echo "Logs will be stored in \"/var/log/borgwrapper/*\""
echo