[HOWTO] Daily incremental backup with rsnapshot

Discussion on remote replication.
Post Reply
crushdepth
Getting the hang of things
Posts: 76
Joined: Thu Mar 26, 2009 8:56 pm

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by crushdepth »

Error messages are logged to the rsnapshot logfile. There is an example shell script to send job results to email here. I am not sure if this would work on a QNAP or not.

Maybe someone whose good at shell scripting could have a go at this :)
efaden
Getting the hang of things
Posts: 65
Joined: Sun Nov 22, 2009 6:42 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by efaden »

That's what I was going to do. The problem is that the QNAP doesn't have mail.
efaden
Getting the hang of things
Posts: 65
Joined: Sun Nov 22, 2009 6:42 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by efaden »

I think I figured out how to send email.... I am working on a script and will post what I get. Thus far...

Add the alias in to /etc/config/ssmtp/revaliases...

Code: Select all

admin:qnap@blah.com:mail.blah.com:25
Then you can use ssmtp to send the mail... here is my test script...

Code: Select all

#!/bin/sh                                                                                                                                                       
# Header Stuff                                                                  
MAILTO="admin@blah.com"                                                  
TO="Admin <admin@blah.com>"                                         
FROM="QNAP <qnap@blah.com>"                                       
SUBJECT="RSnapshot Log"                                                         
                                                                                
# Program                                                                       
MAIL="/usr/sbin/ssmtp"                                                          
#logfile="/var/log/rsnapshot.log"                                               
                                                                                
# Temporary Files                                                               MAILFILE="/tmp/TMPMAIL"                                                         
                                                                                
# Build Mail                                                                    
echo "TO: $TO" > $MAILFILE                                                      
echo "FROM: $FROM" >> $MAILFILE                                                 
echo "SUBJECT: $SUBJECT" >> $MAILFILE                                           
echo "" >> $MAILFILE                                                            
echo "Testing" >> $MAILFILE                                                     
                                                                                
# Send Mail                                                                     
$MAIL $MAILTO < $MAILFILE                                                       
                                                                                
# Remove Temporary Files                                                        
rm -rf $MAILFILE            
crushdepth
Getting the hang of things
Posts: 76
Joined: Thu Mar 26, 2009 8:56 pm

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by crushdepth »

Did you manage to get it to email error messages to you?
efaden
Getting the hang of things
Posts: 65
Joined: Sun Nov 22, 2009 6:42 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by efaden »

Yeah... if you do what I said above I got it to email out messages....
efaden
Getting the hang of things
Posts: 65
Joined: Sun Nov 22, 2009 6:42 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by efaden »

Got a script all done.... I have rsnapshot setup as per the guide.... and then ....

crontab:

Code: Select all

0 0 * * * /share/MD0_DATA/System/rsnapshot_log.sh
/share/MD0_DATA/System/rsnapshot_log.sh:

Code: Select all

 #!/bin/sh                                                                                       
                                                                                                
# Header Stuff                                                                                  
LOG_FILE="/opt/var/log/rsnapshot"                                                               
TMP_LOG_FILE="/tmp/rsnapshot_log.log"                                                           
                                                                                                
MAIL_FILE="/tmp/rsnapshot_log.mail"                                                             
MAIL_TO="my@email.com"                                           
MAIL_HEADER_TO="Me <my@email.com>"         
MAIL_HEADER_FROM="QNAP <qnap@email.com>"                                           
MAIL_HEADER_SUBJECT="RSnapshot Log"                                                             
                                                                                                
MAIL="/usr/sbin/ssmtp"                                                                          
                                                                                                
# Extract Todays Log ( format 30/Mar/2006 )                                                     
fgrep `date +"%d/%b/%Y"` $LOG_FILE > $TMP_LOG_FILE                                              
                                                                                                
# Build Mail                                                                                    
{                                                                                               
        echo "TO: $MAIL_HEADER_TO"                                                              
        echo "FROM: $MAIL_HEADER_FROM"                                                          
        echo "SUBJECT: $MAIL_HEADER_SUBJECT"                                                    
        echo ""                                                                                 
        echo "Backup Report on `date`"                                                          
        egrep "completed|ERROR" $TMP_LOG_FILE                                                   
        echo ""                                                                                 
        echo "Disk Usage:"                                                                      
        /opt/bin/rsnapshot du                                                                   
        echo ""                                                                                 
        /opt/bin/df -h                                                                          
        echo ""                                                                                 
        echo "Full Log:"                                                                        
        echo ""                                                                                 
        cat $TMP_LOG_FILE                                                                       
} > $MAIL_FILE                                                                                  
                                                                                                
# Send Mail                                                                                     
$MAIL $MAIL_TO < $MAIL_FILE                                                                     
                                                                                                
# Remove Temporary Files                                                                        
rm -rf $MAIL_FILE $TMP_LOG_FILE
I think it works.......
efaden
Getting the hang of things
Posts: 65
Joined: Sun Nov 22, 2009 6:42 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by efaden »

Whoops... log getter was wrong. Either need to update the script to grab yesterdays date... OR change the crontab to run BEFORE midnight...

Code: Select all

55 23 * * * /share/MD0_DATA/System/rsnapshot_log.sh
julius
New here
Posts: 3
Joined: Mon Jan 25, 2010 11:21 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by julius »

crushdepth, great job. Many thanks!
I do it successed on TS-459 pro for remote backup under your guide step by step.
1xTS-809U-RP with 8x2T Disk,1xTS-459U with 4x2T Disk,1xTS-459U+ with 4x2T Disk, 1x3 x (TS-459pro with 4x2T Disk)
crushdepth
Getting the hang of things
Posts: 76
Joined: Thu Mar 26, 2009 8:56 pm

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by crushdepth »

Welcome :)

I hope one day rsnapshot will be included in the QNAP firmware. Being able to step back in time and recover a specific version of a file is extremely useful.
User avatar
Q
Experience counts
Posts: 1436
Joined: Wed Sep 05, 2007 4:18 pm
Location: Switzerland
Contact:

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by Q »

I hope one day rsnapshot will be included in the QNAP firmware. Being able to step back in time and recover a specific version of a file is extremely useful.
+1!

i also suggested this once to qnap... and adding a nice web ui for it would be even better. hope to see this or a similar function soon.
I am Q
www.qnap.ch

I don't work at QNAP.
And RAID is really NO backup!
User avatar
Eduardo
Easy as a breeze
Posts: 350
Joined: Tue Jun 30, 2009 2:08 am
Location: Sevilla (Spain)

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by Eduardo »

Using rsnapshot for the last two months. It works flawlessly.
I recovered an important file two weeks ago, and saved some hours of working.
Thanks to Crushdepth!
TS-259Pro+,TS-239 Pro. Firm 3.7.3 Build0801
2xSeagate ST32000542AS CC34 Raid 1 (+1 ST32000542AS Raid 1 ESATA/USB Backup)
Qpkg: MLDonkey, JRE, Micke OpenSSH, Micke Nasreport, Python, CrashPlan, Rsnap.
Ipkg: Rsnapshot, logrotate, heyu
================================================================================================
Looking forward to a (Prolific 2303 or ftdi) USB to serial driver!
hayedid
Getting the hang of things
Posts: 97
Joined: Tue May 19, 2009 11:47 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by hayedid »

I'm having a bit of trouble setting up rsynch/rsnapshot. I have two servers QNAP1 and QNAP2. I have a directory in QNAP1 called DocumentControl. I am wanting this directory to get backed up daily and I am using the following backup command:

backup admin@qnap1:/DocumentControl/ DocumentControl/

When I run "rsnapshot daily" I get the following error:
rsync: link_stat "/DocumentControl" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1508) [Receiver=3.0.7]

Sure enough... if I use putty to log onto QNAP1 and do a "CD /DocumentControl", my directory is not there. Where is the DocumentControl directory actually located? I created it as a new folder off the root that is visible when using my browser (Internet Exporer) and going to \\qnap1 (the same place I see Public, Qdownload, Qrecordings, Qweb, etc).

Thank you.

****UPDATE****.... nevermind... I found it under SHARE.
hayedid
Getting the hang of things
Posts: 97
Joined: Tue May 19, 2009 11:47 am

RE: Having trouble with backups...

Post by hayedid »

Hi. I had rsnapshot configured with the following:
backup admin@qnap1:/share/DocumentControl/ DocumentControl/

I put a text file (text.txt) in my DocumentControl directory and ran "rsnapshot daily" I expected to see "daily.0/DocumentControl/text.txt" in my snapshots folder. Instead, I saw In my snapshots folder, I went to "daily.0/DocumentControl/share" and there was no "text.txt" file backed up.

I then tried the following with better results, but very deep nesting.
backup admin@qnap1:/share/MD0_DATA/DocumentControl/ QNAP1/

Doing this created the Text.TXT file in the following directory
\\qnap2\snapshots\daily.0\QNAP1\share\MD0_DATA\DocumentControl

Why do I have to use MD0_DATA when I can see the files when I go to /share/DocumentControl? Why does the backup contain "QNAP1\share\MD0_DATA\DocumentControl" directory instead of simply "DocumentControl"? I do understand that its giving the fully qualified path, but it's a lot of nesting that, I find to be inconvenient and unnecessary. Is there any way to prevent this?

Thanks.
Peli67
Starting out
Posts: 21
Joined: Fri Feb 08, 2008 6:21 am

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by Peli67 »

It is still hard to believe that Qnap hasnt implemented this realy crucial function :shock:
crushdepth
Getting the hang of things
Posts: 76
Joined: Thu Mar 26, 2009 8:56 pm

Re: [HOWTO] Daily incremental backup with rsnapshot

Post by crushdepth »

Why do I have to use MD0_DATA when I can see the files when I go to /share/DocumentControl? Why does the backup contain "QNAP1\share\MD0_DATA\DocumentControl" directory instead of simply "DocumentControl"? I do understand that its giving the fully qualified path, but it's a lot of nesting that, I find to be inconvenient and unnecessary. Is there any way to prevent this?
Not that I know of. I think you need to use the fully qualified path, which includes MD0_DATA as you said.
Post Reply

Return to “Remote Replication/ Disaster Recovery”