32 lines
1.1 KiB
Bash
32 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
baseurl="https://git.housh.dev/homelab/backup/raw/branch/main"
|
|
systemdir="/etc/systemd/system"
|
|
bindir="/usr/local/bin"
|
|
|
|
# Remove backup service file if it exists and install the service file.
|
|
[ -f "$systemdir/backup.service" ] &&
|
|
systemctl stop backup.timer &&
|
|
systemctl stop backup.service &&
|
|
rm -f "$systemdir/backup.service"
|
|
wget "$baseurl/backup.service" -O "$systemdir/backup.service"
|
|
|
|
# Only download the timer file if it doesn't exist.
|
|
[ ! -f "$systemdir/backup.timer" ] &&
|
|
wget "$baseurl/backup.timer" -O "$systemdir/backup.timer"
|
|
|
|
# Remove the backup script file if it exists and install the backup script.
|
|
[ -f "$bindir/docker-backup" ] && rm -f "$bindir/docker-backup"
|
|
wget "$baseurl/docker-backup.sh" -O "$bindir/docker-backup" &&
|
|
chmod +x "$bindir/docker-backup"
|
|
|
|
# Remove the restore script file if it exists and install the restore script.
|
|
[ -f "$bindir/docker-restore" ] && rm -f "$bindir/docker-restore"
|
|
wget "$baseurl/docker-restore.sh" -O "$bindir/docker-restore" &&
|
|
chmod +x "$bindir/docker-restore"
|
|
|
|
# Start services
|
|
systemctl daemon-reload
|
|
systemctl start backup.timer
|
|
systemctl start backup.service
|