-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
backup.sh
executable file
·24 lines (18 loc) · 1.08 KB
/
backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
#Get the relative path of the backup script
backup_script=$(dirname "$realpath $0")
#Loading the Config
source $backup_script/config/config.sh
#Stopping mastodon processes
systemctl stop mastodon-*
#Generating a database dump backup
su - mastodon -c "cd /home/mastodon/live && pg_dump -Fc mastodon_production > backup.dump"
#Moving the database backup
$AWS s3 mv /home/mastodon/live/backup.dump s3://$s3_bucket_name/$backup_folder_name/home/mastodon/live/backup.dump
#Copying important files
$AWS s3 cp /home/mastodon/live/.env.production s3://$s3_bucket_name/$backup_folder_name/home/mastodon/live/.env.production
$AWS s3 cp /var/lib/redis/dump.rdb s3://$s3_bucket_name/$backup_folder_name/var/lib/redis/dump.rdb
$AWS s3 cp /etc/nginx/sites-available/ s3://$s3_bucket_name/$backup_folder_name/etc/nginx/sites-available/ --recursive
$AWS s3 cp /etc/elasticsearch/jvm.options s3://$s3_bucket_name/$backup_folder_name/etc/elasticsearch/jvm.options
#Starting the mastodon processes
systemctl start mastodon-web mastodon-sidekiq mastodon-streaming