-
-
Save yingziwu/b976e56115f08bda5998152186de733a to your computer and use it in GitHub Desktop.
backup mastodon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
umask 027 | |
# 创建临时目录 | |
BACKUP_TIME=$(date +%s) | |
BACKUP_DIR=/tmp/backup/mstdn/mstdn_${BACKUP_TIME}_$RANDOM | |
[ -e ${BACKUP_DIR} ] || mkdir -p ${BACKUP_DIR} | |
# 生成加密密钥 | |
PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 30) | |
echo $PASSWORD | gpg --recipient 238941C66CC382E5 --encrypt --armor --trust-model always --output $BACKUP_DIR/key.asc | |
# 备份加密数据库 | |
pg_dump -d mastodon_production | 7z a -si -p${PASSWORD} $BACKUP_DIR/db.sql.7z | |
# 上传备份 | |
aws s3 sync /tmp/backup/ s3://mstdn-backup/ --endpoint-url=https://s3.us-west-1.wasabisys.com | |
# 收尾 | |
rm -rf ${BACKUP_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "s3:ListBucket", | |
"Resource": "arn:aws:s3:::mstdn-backup" | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:GetObject" | |
], | |
"Resource": "arn:aws:s3:::mstdn-backup/*" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment