You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or 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
weekly for the previous 4 weeks, and monthly backups
for the previous 12 months.
Run ./mysql_backup --help for usage instructions
@author Andrew Jessup
'''
importos
fromoptparseimportOptionParser
importtime
importdatetime
importlogging
importsubprocess
importshlex
importshutil
SECONDS_IN_A_MONTH=2629743.83
SECONDS_IN_A_WEEK=604800
WEEKLY_BACKUP_COUNT=4
MONTHLY_BACKUP_COUNT=12
defmain():
parser=OptionParser()
parser.add_option("-u", "--user", dest="username", help="Mysql username to connect with", action="store", default="root")
parser.add_option("-p", "--password", dest="password", help="Mysql password to connect with", action="store", default="")
parser.add_option("-H", "--host", dest="host", help="Mysql host to connect to", action="store", default="localhost")
parser.add_option("-d", "--databases", dest="databases", help="Comma seperated list of databases to backup", action="store", default="")
parser.add_option("-D", "--encrypt_dir", dest="encrypt_dir", help="If specfified, will cause encrypted files to be stored in --encrypt_dir with a gpg_key corresponding to this user")
parser.add_option("-U", "--encrypt_user", dest="encrypt_user", help="If specfified along with --encrypt_user, will store an encrypted version of the files in a particular directory")
parser.add_option("-t", "--temp_dir", dest="temp_dir", help="If specified, a user-writeable directory to store working files", default="/tmp", action="store")
parser.add_option("-l", "--log_dir", dest="log_dir", help="Path to log to (logs to stdout if not specified)", default="", action="store")
parser.add_option("-o", "--output_dir", dest="output_dir", help="Path where files are saved", action="store", default=os.path.dirname(__file__))