Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-10-2009, 02:09 PM   #1
LQ Newbie
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15

Rep: Reputation: 1
Rsnapshot du automation

Hi everyone

I have set up a backup system where I work using rsnapshot which works great. I use it to back up 4 linux servers and 4 windows servers which are mounted on the server I use to run rsnapshot on. It works great and I am well pleased with it. I have one small problem, I am trying to create a little script which runs the 'rsnapshot du' command and then outputs the data into a file which I can then read anytime. The reason is that the backups in total are almost 500gb and running rsnapshot du command can sometimes take over an hour to give all the results. So my idea was to have a script which runs each morning at 8am, and outputs into a file which I then set up an alias to output the contents of that file using 'cat'. However I cannot seem to get the script to actually put the output of the command into the file. Its quite strange, if I run the script manually, it seems to work fine. But whenever I add it to cron, it just seems to create an empty file. I know the script is executing because the script also uses the date command to put the time and date the script was run at the top. Am I missing something here, I am quite a noob and was wondering if I would perhaps need to append each line output from 'rsnapshot du' into a variable first and then append it into a file. Any suggestions would be gratefully received.


Old 06-10-2009, 09:17 PM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,927

Rep: Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631Reputation: 2631
Show us the script.
The usual problem in these situations is that cron has a very minimal env, inc $PATH setting, so the rule is:
always specify complete absolute paths to all programs called & files used when in cron.
Old 06-11-2009, 02:42 AM   #3
LQ Newbie
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15

Original Poster
Rep: Reputation: 1
rsnapshot du automation

Hi Chris

You were spot on, I added the full path to rsnapshot and it worked fine. Was confused as it ran fine manually, just didn't run when it was run by cron. Here is the final script:


# script runs 'rsnapshot du' after each twicedaily job completes
# and outputs to 'filename', called from /bin/bkpfinishedemail
# first writes to a tempfile and then copies the contents of the
# tempfile to filename so that filename never holds a half full copy
# of the log if someone tries to read it while it is being written to




if [ ! -e $tempfilename ]
touch $tempfilename

if [ ! -e $filename ]
touch $filename

if grep -q $backup_mount_point /etc/mtab
date '+DATE: %d/%m/%Y TIME:%H:%M:%S%n%n' > $tempfilename
/usr/local/bin/rsnapshot du >> $tempfilename
cat $tempfilename > $filename
exit 0

In the original script I just had the line:

rsnapshot du >> $tempfilename

Once i changed that it was fine.

Thanks for your help. It was driving me mad.



cat, cron, du, rsnapshot

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using rsnapshot with sshfs to backup lpallard Linux - Software 3 08-29-2012 11:41 AM
Rsnapshot and Backup Strategy Woodsman Slackware 2 04-28-2008 11:48 PM
rsnapshot require Lchown ok4life Linux - Software 3 01-11-2008 08:22 PM
Backups with rsnapshot jeremy LQ Articles Discussion 0 07-30-2007 01:58 PM
rsync and rsnapshot madman100 Linux - Newbie 4 10-10-2006 10:33 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration