Open main menu

Changes

250 bytes added ,  07:54, 9 October 2019
add single-transaction switch
# note that i is naked because $(( expression )) is arithmetic expansion in bash
done
if /usr/bin/mysqldump --single-transaction "$DB" > "$backup"; then
echo "backup created successfully"
ls -al "$backup";
For all databases on a host
<source lang="bash">
mysql --execute="show databases" | awk '{print $1}' | grep -iv ^Database$ | sed 's/\(.*\)/mysqldump --single-transaction \1 > \1.'$(date +"%Y%m%d")'.sql/'
# Then just redo the command piped to sh
</source>
 
One of many ways to dump a database from one machine to another
<source lang="bash">
sudo mysqldump --single-transaction mydb | gzip -c | ssh ubuntu@10.0.50.53 'cat > /home/ubuntu/mydb.dump.sql.gz'
</source>
</source>
 
[[Category:Database]]
[[Category:Bash]]
[[Category:System Administration]]