Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if [ "$MYSQLOPT" = 1 ]; then #MySQL section
- echo "$($TIME) - Backing MySQL on $MYSQLSRV" | tee -a $LOG
- if [ ! -d $BKUPDIR/$MYSQLSRV/MySQL ];then
- mkdir -p $BKUPDIR/$MYSQLSRV/MySQL || printerr 'ERROR - $LINENO - Unable to create backup directory for $MYSQLSRV in $BKUPDIR.' #2>> $LOG
- fi
- if ssh $SSHUSER@$MYSQLSRV : 1>> $LOG 2>> $LOG;then
- ssh $SSHUSER@$MYSQLSRV "echo 'show databases\g' | mysql --user='guy' --password='pass' | awk '{if (NR!=1) {print}}'" | (while read -r EACHDBNAME;do
- echo "Working on $EACHDBNAME"
- ssh $SSHUSER@$MYSQLSRV "mysqldump --user='guy' --password='pass' $EACHDBNAME | gzip" 1> $BKUPDIR/$MYSQLSRV/MySQL/$EACHDBNAME.sql.gz #|| printerr 'ERROR - $LINENO - Unable to back up MySQL database $EACHDBNAME on $MYSQLSRV.' #2>> $LOG
- done)
- else
- printerr "ERROR - $LINENO - SSH to $MYSQLSRV failed." 1>> $LOG 2>> $LOG
- fi
- fi
- [guy@place ~]$ /usr/local/bin/Backup.sh -m
- Successfully acquired lock: /tmp/Backup.sh.lock
- 12-18-2010 - 04:25:48 PM - Starting run of Backup.sh. Additional details at the end of the log.
- 04:25:48 PM - Environment is sane, starting backup.
- 04:25:48 PM - Backing MySQL on 2.2.2.2
- Working on information_schema
- Working on delta2
- Working on history
- Working on info_cast
- Working on mysql
- Working on test
- Working on unit_delta
- 04:25:50 PM - Cleaning up
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Server: place
- Script name: Backup.sh
- Script location: /usr/local/bin
- Log: /var/log/backup/2010-12-18-Backup.sh.log
- MySQL option enabled on 67.210.228.150 for the database MYSQLDB.
- Start: 12-18-2010 - 04:25:48 PM
- End: 12-18-2010 - 04:25:50 PM
- Duration: 0 days, 0 hours, 0 minutes, 2 seconds
- Completed successfully!
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [guy@Wplace ~]$ /usr/local/bin/Backup.sh -m
- Successfully acquired lock: /tmp/Backup.sh.lock
- 12-18-2010 - 04:27:07 PM - Starting run of Backup.sh. Additional details at the end of the log.
- 04:27:07 PM - Environment is sane, starting backup.
- 04:27:07 PM - Backing MySQL on 2.2.2.2
- Working on information_schema
- 04:27:10 PM - Cleaning up
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Server: place
- Script name: Backup.sh
- Script location: /usr/local/bin
- Log: /var/log/backup/2010-12-18-Backup.sh.log
- MySQL option enabled on 67.210.228.150 for the database MYSQLDB.
- Start: 12-18-2010 - 04:27:07 PM
- End: 12-18-2010 - 04:27:10 PM
- Duration: 0 days, 0 hours, 0 minutes, 3 seconds
- Completed successfully!
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 04:28:22 PM - Backing MySQL on 67.210.228.150
- + '[' '!' -d /backup/67.210.228.150/MySQL ']'
- + ssh backupuser@67.210.228.150 :
- + ssh backupuser@67.210.228.150 'echo '\''show databases\g'\'' | mysql --user='\''guy'\'' --password='\''pass'\'' | awk '\''{if (NR!=1) {print}}'\'''
- + read -r EACHDBNAME
- + echo 'Working on information_schema'
- Working on information_schema
- + ssh backupuser@67.210.228.150 'mysqldump --user='\''guy'\'' --password='\''pass'\'' information_schema | gzip'
- + read -r EACHDBNAME
- ++ date +%r
- + tee -a /var/log/backup/2010-12-18-Backup.sh.log
- + echo '04:28:25 PM - Cleaning up'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement