From dc1ce6ddb49819971e4d5c8e5582c214dc858a73 Mon Sep 17 00:00:00 2001 From: inexcode Date: Fri, 17 Jan 2020 17:39:13 +0300 Subject: [PATCH] Initial commit --- LICENSE | 14 ++++++++++++++ Mastodon database/backup.sh | 5 +++++ Mastodon database/mastodon-database-backup.conf | 5 +++++ Mastodon database/mastodon-database-backup.service | 9 +++++++++ Mastodon database/mastodon-database-backup.timer | 7 +++++++ Mastodon database/mastodon-database-prune.service | 8 ++++++++ Mastodon database/mastodon-database-prune.timer | 7 +++++++ Pixelfed/backup.sh | 1 + Pixelfed/pixelfed-backup.conf | 5 +++++ Pixelfed/pixelfed-backup.service | 9 +++++++++ Pixelfed/pixelfed-backup.timer | 7 +++++++ Pixelfed/pixelfed-prune.service | 8 ++++++++ Pixelfed/pixelfed-prune.timer | 7 +++++++ README.md | 1 + 14 files changed, 93 insertions(+) create mode 100644 LICENSE create mode 100644 Mastodon database/backup.sh create mode 100644 Mastodon database/mastodon-database-backup.conf create mode 100644 Mastodon database/mastodon-database-backup.service create mode 100644 Mastodon database/mastodon-database-backup.timer create mode 100644 Mastodon database/mastodon-database-prune.service create mode 100644 Mastodon database/mastodon-database-prune.timer create mode 100644 Pixelfed/backup.sh create mode 100644 Pixelfed/pixelfed-backup.conf create mode 100644 Pixelfed/pixelfed-backup.service create mode 100644 Pixelfed/pixelfed-backup.timer create mode 100644 Pixelfed/pixelfed-prune.service create mode 100644 Pixelfed/pixelfed-prune.timer create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5a8e332 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/Mastodon database/backup.sh b/Mastodon database/backup.sh new file mode 100644 index 0000000..6ad8029 --- /dev/null +++ b/Mastodon database/backup.sh @@ -0,0 +1,5 @@ +RETENTION_DAYS=7 +RETENTION_WEEKS=4 +RETENTION_MONTHS=6 +RETENTION_YEARS=3 +RESTIC_PASSWORD= diff --git a/Mastodon database/mastodon-database-backup.conf b/Mastodon database/mastodon-database-backup.conf new file mode 100644 index 0000000..0114360 --- /dev/null +++ b/Mastodon database/mastodon-database-backup.conf @@ -0,0 +1,5 @@ +RETENTION_DAYS=7 +RETENTION_WEEKS=4 +RETENTION_MONTHS=6 +RETENTION_YEARS=3 +RESTIC_PASSWORD= \ No newline at end of file diff --git a/Mastodon database/mastodon-database-backup.service b/Mastodon database/mastodon-database-backup.service new file mode 100644 index 0000000..e9eeca6 --- /dev/null +++ b/Mastodon database/mastodon-database-backup.service @@ -0,0 +1,9 @@ +[Unit] +Description=Mastodon database backup service +[Service] +User=mastodon +Group=restic +Type=oneshot +ExecStart=/bin/bash /home/mastodon/backup.sh +ExecStartPost=/usr/bin/restic forget -r /backups/mastodon/database --tag systemd.timer --group-by "paths,tags" --keep-daily $RETENTION_DAYS --keep-weekly $RETENTION_WEEKS --keep-monthly $RETENTION_MONTHS --keep-yearly $RETENTION_YEARS +EnvironmentFile=/home/mastodon/.config/mastodon-database-backup.conf \ No newline at end of file diff --git a/Mastodon database/mastodon-database-backup.timer b/Mastodon database/mastodon-database-backup.timer new file mode 100644 index 0000000..9ea01c0 --- /dev/null +++ b/Mastodon database/mastodon-database-backup.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Backup mastodon database with restic daily +[Timer] +OnCalendar=daily +Persistent=true +[Install] +WantedBy=multi-user.target diff --git a/Mastodon database/mastodon-database-prune.service b/Mastodon database/mastodon-database-prune.service new file mode 100644 index 0000000..faad268 --- /dev/null +++ b/Mastodon database/mastodon-database-prune.service @@ -0,0 +1,8 @@ +[Unit] +Description=Mastodon database backup service (data pruning) +[Service] +User=mastodon +Group=restic +Type=oneshot +ExecStart=/usr/bin/restic -r /backups/mastodon/database prune +EnvironmentFile=/home/mastodon/.config/mastodon-database-backup.conf diff --git a/Mastodon database/mastodon-database-prune.timer b/Mastodon database/mastodon-database-prune.timer new file mode 100644 index 0000000..dedfc35 --- /dev/null +++ b/Mastodon database/mastodon-database-prune.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Prune data from the restic repository monthly (Mastodon db) +[Timer] +OnCalendar=weekly +Persistent=true +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/Pixelfed/backup.sh b/Pixelfed/backup.sh new file mode 100644 index 0000000..800583c --- /dev/null +++ b/Pixelfed/backup.sh @@ -0,0 +1 @@ +pg_dump -Fc pixelfed -f /home/pixelfed/database.bak && restic backup -r /backups/pixelfed/database --tag systemd.timer.database /home/pixelfed/database.bak && rm /home/pixelfed/database.bak && restic backup -r /backups/pixelfed/database --tag systemd.timer.media /home/pixelfed/pixelfed/storage/app/public \ No newline at end of file diff --git a/Pixelfed/pixelfed-backup.conf b/Pixelfed/pixelfed-backup.conf new file mode 100644 index 0000000..6ad8029 --- /dev/null +++ b/Pixelfed/pixelfed-backup.conf @@ -0,0 +1,5 @@ +RETENTION_DAYS=7 +RETENTION_WEEKS=4 +RETENTION_MONTHS=6 +RETENTION_YEARS=3 +RESTIC_PASSWORD= diff --git a/Pixelfed/pixelfed-backup.service b/Pixelfed/pixelfed-backup.service new file mode 100644 index 0000000..25e72df --- /dev/null +++ b/Pixelfed/pixelfed-backup.service @@ -0,0 +1,9 @@ +[Unit] +Description=Pixelfed data backup service +[Service] +User=pixelfed +Group=restic +Type=oneshot +ExecStart=/bin/bash /home/pixelfed/backup.sh +ExecStartPost=/usr/bin/restic forget -r /backups/pixelfed/database --group-by "paths,tags" --keep-daily $RETENTION_DAYS --keep-weekly $RETENTION_WEEKS --keep-monthly $RETENTION_MONTHS --keep-yearly $RETENTION_YEARS +EnvironmentFile=/home/pixelfed/.config/pixelfed-backup.conf \ No newline at end of file diff --git a/Pixelfed/pixelfed-backup.timer b/Pixelfed/pixelfed-backup.timer new file mode 100644 index 0000000..daa5df4 --- /dev/null +++ b/Pixelfed/pixelfed-backup.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Backup pixelfed with restic daily +[Timer] +OnCalendar=daily +Persistent=true +[Install] +WantedBy=multi-user.target diff --git a/Pixelfed/pixelfed-prune.service b/Pixelfed/pixelfed-prune.service new file mode 100644 index 0000000..be667c8 --- /dev/null +++ b/Pixelfed/pixelfed-prune.service @@ -0,0 +1,8 @@ +[Unit] +Description=Pixelfed data backup service (data pruning) +[Service] +User=pixelfed +Group=restic +Type=oneshot +ExecStart=/usr/bin/restic -r /backups/pixelfed/database prune +EnvironmentFile=/home/pixelfed/.config/pixelfed-backup.conf diff --git a/Pixelfed/pixelfed-prune.timer b/Pixelfed/pixelfed-prune.timer new file mode 100644 index 0000000..f653972 --- /dev/null +++ b/Pixelfed/pixelfed-prune.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Prune data from the restic repository monthly (pixelfed) +[Timer] +OnCalendar=weekly +Persistent=true +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ab11a13 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Backup services of my servers