34.204.169.76 |    

Navigation

Google Advertisement

Get a mysqldump of all mysql databases.

mysqldump.sh
  1. #!/bin/bash
  2. # *************************************************************
  3. # file: mysqldump.sh
  4. # date: 2007-07-04 00:22
  5. # author: (c) by Marko Schulz - <info@tuxnet24.de>
  6. # description: Get a mysqldump of all mysql databases.
  7. # *************************************************************
  8.  
  9. # name of database user ( must have LOCK_TABLES rights )...
  10. dbUsername="backupuser"
  11.  
  12. # password of database user...
  13. dbPassword="SeCret"
  14.  
  15. # path to backup directory...
  16. dbBackup="/data/backup/mysqldump"
  17.  
  18. # *************************************************************
  19. # program action...
  20.  
  21. # get current date ( YYYY-MM-DD )...
  22. date=$( date +%Y-%m-%d )
  23.  
  24. # create backup directory if not exists...
  25. [ ! -d "$dbBackup" ]  && mkdir -p $dbBackup
  26.  
  27. # delete all old mysqldumps...
  28. find $dbBackup/ -type f -name '*.sql.gz' -exec rm -rf {} ';' >/dev/null 2>&1
  29.  
  30. # loop all databases...
  31. for db in $( mysql -u $dbUsername --password=$dbPassword -Bse "show databases" ); do
  32. 	# get mysqldump of current database...
  33. 	mysqldump -u $dbUsername --password=$dbPassword --opt --databases $db | gzip -9 >${dbBackup}/${db}-${date}.sql.gz
  34. done
  35.  
  36. # *************************************************************
  37. # EOF
Parsed in 0.004 seconds at 280.83 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 3 users online.

Tags Cloud

Latest snippets
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)
STDERR
(Bash::Function)
radius
(CSS)
shadow
(CSS)
rotate
(CSS)
create_function
(JavaScript::Snippets)