I actually just pipe the output of the script I shared earlier to another script that takes care of timestamping and emailing:
#!/bin/bash subject="$1" mail_to="$2" mail_from="$3" [ -z "$subject" ] && subject="$(IFS= read -r line && echo $line)" [ -z "$mail_to" ] && mail_to="[email protected]" [ -z "$mail_from" ] && mail_from="[email protected]" export TZ="US/Eastern" ( echo -e "To: $mail_to\nFrom: $mail_from\nSubject: $subject\n" while IFS= read -r line; do printf "%s: %s\n" "$(date "+%Y-%m-%d %H:%M:%S %Z")" "$line" done echo -e '\n' )| sendmail -f $mail_from $mail_to combined, it sends me an email similar to this one: 2013-06-12 06:55:21 EDT: grabbing database to dump 2013-06-12 06:55:21 EDT: dumping these databases: 'wordpress mediawiki mysql' 2013-06-12 06:55:21 EDT: dumping database wordpress 2013-06-12 06:55:32 EDT: dumping database mediawiki 2013-06-12 06:58:22 EDT: dumping database mysql 2013-06-12 06:58:22 EDT: -- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. 2013-06-12 07:00:44 EDT: rdiffing databases Which is enough to let me see what is going on, how much time it is taking, and that it actually is backing up everything without errors. On Thu, Jun 13, 2013 at 11:16 AM, MasteRTriX <[email protected]> wrote: > For this tasks I started using safekeep (it´s like a frontend for rdiff) > The main advantage is that it emails you with the backup results, and is > pretty easy to configure with a config file per task. > > I used to use rdiff standalone but I like better with safekeep. > > > El 11/06/13 14:17, Travis escribió: > >> I've been using rdiffbackup for mysql backups for years, and currently >> just dump all my databases to a temporary directory, rdiff-backup >> that, then delete the temporary directory (since rdiff keeps a current >> mirror anyway). The downside is it uses extra space equivalent to all >> your current version backups while the script is running, so if you >> don't have that much extra space, I don't know of the solution. Here >> is the script I use: >> >> #!/bin/bash >> cd /path/to/backup/ >> USERNAME="root" >> PASSWORD="password" >> >> # subject for email >> echo "dumpdbs report" >> >> echo "grabbing database to dump" >> >> # list them manually >> #DATABASES="wordpress mediawiki" >> # or automatically >> DATABASES=$(mysql -u$USERNAME -p$PASSWORD -e "SHOW DATABASES;" | tr -d >> "| " | grep -v Database) >> >> echo "dumping these databases: '$(echo "$DATABASES" | tr '\n' ' ')'" >> >> # backup databases >> mkdir -p tmp >> for database in $DATABASES >> do >> echo "dumping database $database" >> # rdiff-backup is useless on compressed data, so don't do this anymore >> # mysqldump -u$USERNAME -p$PASSWORD --single-transaction >> $database | bzip2 -c > ./tmp/$database.sql.bz2 >> mysqldump -u$USERNAME -p$PASSWORD --single-transaction >> $database > ./tmp/$database.sql >> done >> >> echo "rdiffing databases" >> >> rdiff-backup ./tmp ./dbs >> rm -rf tmp >> >> >> On Tue, Jun 11, 2013 at 10:59 AM, Eric Beversluis >> <[email protected]> wrote: >>> >>> I want to create a cron job to do mysqldump and run the output through >>> rdiff-backup so it goes right into /home/eric/repository/mysql. Can >>> someone give me the correct syntax for that? Do I have to do the mysql >>> dump to a particular file and then rdiff that file? (Which would mean >>> I'd have to overwrite that file each time.) Or is there some way I can >>> just pipe the mysqldump output right through rdiff-backup? >>> >>> Thanks >>> >>> >>> _______________________________________________ >>> rdiff-backup-users mailing list at [email protected] >>> https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users >>> Wiki URL: >>> http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki >> >> _______________________________________________ >> rdiff-backup-users mailing list at [email protected] >> https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users >> Wiki URL: >> http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki > > _______________________________________________ rdiff-backup-users mailing list at [email protected] https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
