Created
November 27, 2015 22:59
-
-
Save joshmn/220fe03bc162118e23da to your computer and use it in GitHub Desktop.
mediawiki backup to s3
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
# backup | |
echo Performing Mediawiki backup... | |
# Perform MySQL dump | |
echo Performing MySQL dump... | |
mysqldump <database_name> -h<database_host> -u<database_username> -p<database_password> > /opt/backup/data/mysql.bck | |
# Create mediawiki tarball | |
echo Creating mediawiki tarball... | |
cd /opt/mediawiki/ | |
tar cf /opt/backup/data/backup.tar mediawiki-1.22.2 | |
# Append /etc/mediawiki directory to tarball | |
echo Appending /etc/mediawiki to tarball... | |
cd /etc/mediawiki | |
tar rf /opt/backup/data/backup.tar . | |
# Append MySQL dump to tarball | |
echo Appending MySQL dump to tarball... | |
cd /opt/backup/data/ | |
tar rf /opt/backup/data/backup.tar mysql.bck | |
# Create date variable | |
DATE=$(date +"%Y%m%d%H%M") | |
# Compress tarball | |
echo Compressing mediawiki tarball... | |
cd /opt/backup/data | |
gzip -c backup.tar > backup_$DATE.tgz | |
# Remove intermittent artifacts | |
echo Removing intermittent artifacts... | |
rm -f backup.tar mysql.bck | |
# Push backup to Amazon S3 for offsite storage | |
echo Pushing backup to Amazon S3 for offsite storage... | |
s3put brigopedia/backup_$DATE.tgz backup_$DATE.tgz | |
echo Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment