Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My rsnapshot configuration:

snapshot_root   /.snapshots/
backup  /home/user          localhost/
backup_script   /usr/local/backup_mysql.sh      localhost/mysql/

Using this file:

NOW=$(date +"%m-%d-%Y") # mm-dd-yyyy format
FILE=""                 # used in a loop

### Server Setup ###
#* MySQL login user name *#
MUSER="root"

#* MySQL login PASSWORD name *#
MPASS="YOUR-PASSWORD"

#* MySQL login HOST name *#
MHOST="127.0.0.1"

#* MySQL binaries *#
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"

# get all database listing
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"

# start to dump database one by one
for db in $DBS
do
FILE=$BAK/mysql-$db.$NOW-$(date +"%T").gz
# gzip compression for each backup file
$MYSQLDUMP --single-transaction -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done

It dumps the databases under /

I then tried with the following: http://bash.cyberciti.biz/backup/rsnapshot-remote-mysql-backup-shell-script/

I got:

rsnapshot hourly
----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these options:
/usr/bin/rsnapshot hourly
----------------------------------------------------------------------------
ERROR: backup_script /usr/local/backup_mysql.sh returned 1
WARNING: Rolling back "localhost/mysql/"


ls -la /.snapshots/hourly.0/localhost/mysql
total 8
drwxr-xr-x 2 root root 4096 Nov 23 17:43 ./
drwxr-xr-x 4 root root 4096 Nov 23 18:20 ../

What exactly am I doing wrong?

EDIT:

# /usr/local/backup_mysql.sh
*** Dumping MySQL Database ***
Database> information_schema..cphulkd..eximstats..horde..leechprotect..logaholicDB_ns1..modsec..mysql..performance_schema..roundcube..test..
*** Backup done [ files wrote to /.snapshots/tmp/mysql] ***
root@ns1 [~]# ls -la /.snapshots/tmp/mysql
total 8040
drwxr-xr-x 2 root root    4096 Nov 23 18:41 ./
drwxr-xr-x 3 root root    4096 Nov 23 18:41 ../
-rw-r--r-- 1 root root    1409 Nov 23 18:41 cphulkd.18_41_45pm.gz
-rw-r--r-- 1 root root  113522 Nov 23 18:41 eximstats.18_41_45pm.gz
-rw-r--r-- 1 root root    4583 Nov 23 18:41 horde.18_41_45pm.gz
-rw-r--r-- 1 root root   71757 Nov 23 18:41 information_schema.18_41_45pm.gz
-rw-r--r-- 1 root root     692 Nov 23 18:41 leechprotect.18_41_45pm.gz
-rw-r--r-- 1 root root    2603 Nov 23 18:41 logaholicDB_ns1.18_41_45pm.gz
-rw-r--r-- 1 root root     745 Nov 23 18:41 modsec.18_41_45pm.gz
-rw-r--r-- 1 root root  138928 Nov 23 18:41 mysql.18_41_45pm.gz
-rw-r--r-- 1 root root    1831 Nov 23 18:41 performance_schema.18_41_45pm.gz
-rw-r--r-- 1 root root    3610 Nov 23 18:41 roundcube.18_41_45pm.gz
-rw-r--r-- 1 root root     436 Nov 23 18:41 test.18_41_47pm.gz

MySQL Backup seems fine.

share|improve this question
    
Run /usr/local/backup_mysql.sh manually, paste us the output. Exit code 1 is far too vague. –  Jay Nov 23 '12 at 23:40
    
Edited with new info –  Tiffany Walker Nov 23 '12 at 23:43
    
Your script doesn't contain Backup done, so how it is output? Can you also run the script then execute echo $? and paste that in? –  Jay Nov 23 '12 at 23:50
add comment

1 Answer

up vote 0 down vote accepted

I found the problem. The sample scripts are not coded correctly. Something to do with the VERBOSE commands.

EDIT: not my mistake, just the coders who made the scripts.

comment out the verbose lines or change verbose to 1 and script works fine.

share|improve this answer
    
Please expand your answer so that others have a chance to learn from your mistakes. –  Martin Schröder Nov 24 '12 at 19:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.