![]() |
MySQL automatic backup script I can run??
Anybody have a good one i can execute via the shell and also option to run daily via cron?
Ice is gay |
bump i need this tooooooooooo.
|
Not sure about InnoDB tables, but can't you put the following in a shell script:
mysqldump --user=[user] --pass=[pass] --opt [database] > /path/to/backup.sql |
Quote:
|
Quote:
|
To back-up all db's:
mysqldump --all-databases > all_databases.sql |
|
niceeeeeeeeeeeee
|
Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.
#!/bin/sh # List all of the MySQL databases that you want to backup in here, # each seperated by a space databases="name of database" # Directory where you want the backup files to be placed backupdir=/path/to/directory # MySQL dump command, use the full path name here mysqldumpcmd=/usr/bin/mysqldump # MySQL Username and password userpassword=" --user=username --password=your password" # MySQL dump options dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables" # Unix Commands gzip=/bin/gzip uuencode=/usr/bin/uuencode mail=/usr/sbin/sendmail # Send Backup? Would you like the backup emailed to you? # Set to "y" if you do sendbackup="n" subject="Your MySQL Backup" mailto="[email protected]" # Create our backup directory if not already there mkdir -p ${backupdir} if [ ! -d ${backupdir} ] then echo "Not a directory: ${backupdir}" exit 1 fi # Dump all of our databases echo "Dumping MySQL Database" for database in $databases do $mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump done # Compress all of our backup files echo "Compressing Dump File" for database in $databases do rm -f ${backupdir}/${database}.dump.gz $gzip ${backupdir}/${database}.dump done # Send the backups via email if [ $sendbackup = "y" ] then for database in $databases do $uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu $mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu done fi # And we're done ls -l ${backupdir} echo "Dump Successful and Complete!" exit |
Quote:
|
What's this about my Ass Queue? I'm not very good with computars.
|
Quote:
Just be sure to enter the correct info for 'databases', 'backupdir', 'user', and 'password' |
script above is rippeee works hotttttt thxxxx
|
Quote:
yup did that thxxxxxxxxxxxxx |
Dump Successful and Complete!
|
I could write you a custom one ;)
|
Quote:
I have one I wrote in Perl that also tars all the DBs together and then Zips it. They get saved with a datestamp as well so I can roll back a few days if need be. At some point I'm going to upgrade it to also FTP the DB backup to another server so if one goes down I still have backups. |
Quote:
Code:
-rwx------ 1 root root 3426 2007-09-29 13:16 backer.sh |
nice shell script above.. perfect for making a gmail account for the database and shipping it off to that account daily or whenever you want to run it from the cron.
quality reply there. cheers. |
all this code talk is getting me HARD
|
all this code talk is getting me HARD
|
all this code talk is getting me HARD
|
Quote:
Couldn't find backer.sh on one of my FreeBSD and Linux servers. |
Quote:
If you always design for the least common amount of bourne compatibility, the shells will usually work. Don't rely on linux or BSD nuances by themselves, test if you have to, and abusing awk is never wrong. :thumbsup |
Quote:
|
i make great threads
|
soRRy cant HELP "(
|
Quote:
|
All times are GMT -7. The time now is 12:02 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123