Skip to content

Instantly share code, notes, and snippets.

@avramovic
Last active October 6, 2024 20:15
Show Gist options
  • Save avramovic/1fb7f82818628e43c881a596314e8769 to your computer and use it in GitHub Desktop.
Save avramovic/1fb7f82818628e43c881a596314e8769 to your computer and use it in GitHub Desktop.
Simple linux shell backup to s3 with s3cmd
#!/bin/bash
if [ -z "$1" ]
then
echo "No database name supplied, usage:"
echo $0 database
exit 1
fi
DBNAME=$1
SQLDUMP="${DBNAME}_dump_$(date +'%Y%m%d%H%M').sql.gz"
echo "Creating backup of database $DBNAME to $SQLDUMP"
/usr/bin/mysqldump --databases $DBNAME | gzip -9 > $SQLDUMP
echo "Dump Zipped up"
echo "Uploading zipped dump to the Amazon S3 bucket…"
/usr/bin/s3cmd put $SQLDUMP s3://backup.garageband.rocks/mysql/$SQLDUMP
echo "Removing the backup file $SQLDUMP"
rm $SQLDUMP
echo "WooHoo! All done"
#!/bin/bash
if [ -z "$1" ]
then
echo "No domain name supplied, usage:"
echo $0 domain
exit 1
fi
DOMAIN=$1
BACKUPFILE="${DOMAIN}_backup_$(date +'%Y%m%d%H%M').tar.gz"
echo "Creating backup of files from ~/web/${DOMAIN} to $BACKUPFILE"
tar -zcvf $BACKUPFILE --exclude='.git' -C ~/web/${DOMAIN} public_html
echo "Dump Zipped up"
echo "Uploading zipped dump to the Amazon S3 bucket…"
/usr/bin/s3cmd put $BACKUPFILE s3://backup.garageband.rocks/files/$BACKUPFILE
echo "Removing the backup file $BACKUPFILE"
rm $BACKUPFILE
echo "WooHoo! All done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment