admin-scripts/bin/.archived/server0_backup.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

2024-07-20 23:15:56 +02:00
#!/usr/bin/env bash
set -eu
2024-07-22 07:20:12 +02:00
TEMP_DIR=$(mktemp -d)
trap 'sudo -u mastodon mv /home/mastodon/db-backup.sql.temp /home/mastodon/db-backup.sql' SIGHUP SIGINT SIGQUIT SIGTERM
trap 'rm -rf $TEMP_DIR' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
trap 'rm -rv /home/mastodon/db-backup.sql.temp' EXIT
2024-07-20 23:15:56 +02:00
sudo -u mastodon mv -v /home/mastodon/db-backup.sql /home/mastodon/db-backup.sql.temp
sudo -u mastodon pg_dump -U mastodon -Fc mastodon_production -p 5432 -f /home/mastodon/db-backup.sql
2024-07-23 04:41:19 +02:00
mkdir "${TEMP_DIR}/etc"
etc_copy_items=(
"caddy"
"docker"
"postgresql"
"systemd/network"
"thelounge"
)
for item in "${etc_copy_items[@]}"; do
rsync -avz "/etc/$item" "${TEMP_DIR}/etc"
done
2024-07-22 07:20:12 +02:00
mkdir "${TEMP_DIR}/log"
rsync -avz /var/log/ "${TEMP_DIR}/log"
mkdir "${TEMP_DIR}/jas"
2024-07-23 04:41:19 +02:00
jas_copy_items=(
2024-07-22 07:20:12 +02:00
"cdn"
"docker"
"public"
".byobu"
".config"
".gmcapsulerc"
".muttrc"
".ssh"
".zshrc"
".gemini-certs"
)
2024-07-23 04:41:19 +02:00
for item in "${jas_copy_items[@]}"; do
2024-07-22 07:20:12 +02:00
rsync -avz "/home/jas/$item" "${TEMP_DIR}/jas"
done
2024-07-23 04:41:19 +02:00
rclone sync "${TEMP_DIR}"/ minio:server0-backup/
2024-07-22 07:20:12 +02:00
2024-07-23 05:16:37 +02:00
rclone copy -c /home/mastodon/db-backup.sql minio:server0-backup/
rclone copy -c /home/mastodon/live/.env.production minio:server0-backup/
2024-07-20 23:15:56 +02:00
2024-08-07 19:23:07 +02:00
aws s3 sync --acl public-read /home/mastodon/live/public/system s3://mastodata --endpoint=http://100.82.153.83:9000
2024-07-20 23:15:56 +02:00
exit 0