Difference between revisions of "Mysqldump all tables from database in separate files"
From DevOps Notebook
(Created page with "<syntaxhighlight lang="bash"> #!/bin/bash USER=myuser PASSWORD=mypwd DATABASE=nameofdb for i in $(mysql -uUser -pPASSWORD DATABASE -e "show tables;"|grep -v Tables_in_);do my...") |
|||
Line 8: | Line 8: | ||
tar -cjvf "backup_mysql_"$(date +'%Y%m%d')".tar.bz2" /destination/dir/*.sql | tar -cjvf "backup_mysql_"$(date +'%Y%m%d')".tar.bz2" /destination/dir/*.sql | ||
− | </ | + | </syntaxhighlight> |
Revision as of 16:51, 9 October 2020
#!/bin/bash
USER=myuser
PASSWORD=mypwd
DATABASE=nameofdb
for i in $(mysql -uUser -pPASSWORD DATABASE -e "show tables;"|grep -v Tables_in_);do mysqldump -u$USER -p$PASSWORD $DATABASE $i > /destination/dir/$i".sql";done
tar -cjvf "backup_mysql_"$(date +'%Y%m%d')".tar.bz2" /destination/dir/*.sql