Skip to content

Instantly share code, notes, and snippets.

@renegarcia
Last active August 31, 2023 20:50
Show Gist options
  • Save renegarcia/fc621892f38dae7f885fdebcf1fbdbfc to your computer and use it in GitHub Desktop.
Save renegarcia/fc621892f38dae7f885fdebcf1fbdbfc to your computer and use it in GitHub Desktop.
Database backup for python anywhere
#!/bin/bash
USERNAME="writeyourusernmehere"
HOST="$USERNAME.mysql.pythonanywhere-services.com"
TABLENAME='your table name'
NOW=`date --iso-8601=seconds`
DBDIR=$HOME/db-backup
BACKUP_FILE="$DBDIR"/db-backup-"$NOW".sql.gz
mysqldump -u $USERNAME -h $HOST --set-gtid-purged=OFF --no-tablespaces --column-statistics=0 "$TABLENAME" | gzip > "$BACKUP_FILE"
@renegarcia
Copy link
Author

Make sure you create the db-backup folder first and place this file in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment