Last active
May 5, 2017 19:20
-
-
Save edwardtoday/9eaeedaa3b9b42447b12 to your computer and use it in GitHub Desktop.
Backup ghost blog related files to s3 bucket
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 | |
# create directories | |
rm -rf /tmp/ghost-backup | |
rm /tmp/ghost-backup*.tar.gz | |
mkdir -p /tmp/ghost-backup/ | |
mkdir -p /tmp/ghost-backup/etc/ | |
mkdir -p /tmp/ghost-backup/etc/nginx/ | |
mkdir -p /tmp/ghost-backup/usr/local/etc/ | |
mkdir -p /tmp/ghost-backup/var/www/ghost/content/ | |
# copy files to backup | |
rsync -av --delete /etc/sysctl.conf /tmp/ghost-backup/etc/ | |
rsync -av --delete /etc/nginx/ /tmp/ghost-backup/etc/nginx/ | |
rsync -av --delete /usr/local/etc/le-renew-webroot.ini /tmp/ghost-backup/usr/local/etc/ | |
rsync -av --delete /var/www/ghost/content/ /tmp/ghost-backup/var/www/ghost/content/ | |
# log nginx environment | |
nginx -v > /tmp/ghost-backup/nginx-version.txt | |
openssl version > /tmp/ghost-backup/openssl-version.txt | |
# create archive | |
cd /tmp/ghost-backup/ | |
tar -czf /tmp/ghost-backup-$(date '+%Y%m%d-%H%M%S').tar.gz /tmp/ghost-backup/ | |
# upload to s3 | |
# usage of s3cmd can be found at https://github.com/s3tools/s3cmd | |
s3cmd -v put *.tar.gz s3://your-bucket-name/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment