Backups are crucial!
Since that is fact I wrote a little script in Python to easily backup mysql databases on a linux server.
Python Mysqldump Backup 1.1 (858 bytes, 111 hits)
How do i configure it?
After you downloaded the script to your Linux server you will need a few Linux packages. Execute the following commands as root:
apt-get update
apt-get install python mysqldump bzip2
What does it do?
This script dumps a certain database (or all databases) into a single mysql file, which is zipped (bzip2) afterwards.
Now edit the script with your preferred editor.
vim mysqldump-backup.py
Customize the following lines:
# 2. Config
mysqlUser = “root”
mysqlPwd = “YOUR_PASSWORD”
mysqlDatabase = “–all-databases”
dumpDir = “/tmp/”
dumpFile = “mysqldump-” + strftime(“%Y-%m-%d-%H-%M-%S”, gmtime()) + “.sql”
The last step is to make the script executable:
chmod u +x mysqldump-backup-1.1.py
Thats it!
You can now run the script:
/path/to/the/script/mysqldump-backup-1.1.py
To run it daily (crontab):
crontab -e
Add at the bottom:
0 3 * * * /path/to/the/script/mysqldump-backup.py
Now your databases will be backupped daily at 03:00 am
Download
Python Mysqldump Backup 1.1 (858 bytes, 111 hits)
Changelog
1.1
- Removed trailing semicolons
- Renamed variables
1.0
Have fun!
Andreas Glaser aka JaZz