equal
deleted
inserted
replaced
|
1 #!/bin/bash |
|
2 |
|
3 INSTANCE=$1 |
|
4 DATE=`date --iso-8601` |
|
5 |
|
6 BUCKET="pleroma-${INSTANCE//_/-}-backup" |
|
7 BACKUP_DIR="/tmp/s3-backup/$BUCKET" |
|
8 BACKUP_TAR="/tmp/s3-backup/$BUCKET-$DATE.tgz" |
|
9 |
|
10 DB_NAME="pleroma_$INSTANCE" |
|
11 CONFIG="/etc/pleroma/$INSTANCE.config.exs" |
|
12 |
|
13 UPLOADS_DIR=`grep uploads $CONFIG | cut -d '"' -f 2` |
|
14 STATIC_DIR=`grep static $CONFIG | cut -d '"' -f 2` |
|
15 |
|
16 mkdir -m 775 -p "$BACKUP_DIR/" |
|
17 chown root:postgres "$BACKUP_DIR/" |
|
18 |
|
19 su postgres -c "pg_dump -d $DB_NAME --format=custom -f $BACKUP_DIR/$DB_NAME.pgdump" |
|
20 cp $CONFIG "$BACKUP_DIR/" |
|
21 cp -r $UPLOADS_DIR "$BACKUP_DIR/" |
|
22 cp -r $STATIC_DIR "$BACKUP_DIR/" |
|
23 |
|
24 tar -zc -f $BACKUP_TAR $BACKUP_DIR |
|
25 aws s3 mb "s3://$BUCKET/" |
|
26 aws s3 cp $BACKUP_TAR "s3://$BUCKET/" |