Skip to content

Instantly share code, notes, and snippets.

@kylehotchkiss
Created August 15, 2011 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylehotchkiss/1145780 to your computer and use it in GitHub Desktop.
Save kylehotchkiss/1145780 to your computer and use it in GitHub Desktop.
Wordpress backup. Needs python, mysql, and bzip to work. Make it executable and place it in your cron for daily backups
#!/usr/bin/env python
##
## Backup for Wordpress
## By Hotchkissmade / Kyle Hotchkiss
##
import time, os
# ------------- #
# Configuration #
# ------------- #
mysqluser = 'debian-sys-maint' # Debian & deriv. can use the debian-sys-maint account for this.
mysqlpass = '' # debian sys main pass in /etc/mysql/debian.cnf
mysqlhost = 'localhost'
database = ''
# ------------- #
# Startup Stuff #
# ------------- #
home = os.path.expanduser("~")
if os.path.isdir(home + "/Wordpress") != True:
os.mkdir(home + "/Wordpress")
# ------------------- #
# Backup the database #
# ------------------- #
os.system("mysqldump --add-drop-table -h " + mysqlhost + " -u" + mysqluser + " -p" + mysqlpass + " " + database + " | bzip2 -c > ~/Wordpress/wp" + time.strftime("%m%d%y") + ".sql.bz2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment