25 lines
689 B
Bash
Executable file
25 lines
689 B
Bash
Executable file
#!/bin/bash
|
|
|
|
relative_path="$(dirname "$0")"
|
|
|
|
if ! source "$relative_path/.env"; then
|
|
echo "Cannot source .env file, exiting."
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# Install borgbackup and/or cron if not already installed.
|
|
which borg > /dev/null || sudo apt install -y borgbackup
|
|
which crontab > /dev/null || sudo apt install -y cron
|
|
|
|
|
|
# ARK "Saved" directory path.
|
|
backup_target="$LGSM_ROOT/serverfiles/ShooterGame/Saved"
|
|
|
|
|
|
for repo in "${BORG_REPOS[@]}"; do
|
|
borg init -e none "$repo"
|
|
borg create -C lzma "$repo::Saved_{now:%Y-%m-%d_%H-%M-%S}" "$backup_target"
|
|
borg prune --keep-within=2d --keep-daily=7 --keep-weekly=4 --keep-monthly=12 --keep-yearly=10 "$repo"
|
|
borg compact "$repo"
|
|
done
|