Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rsnapshot won't actually back anything up
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
arantius
n00b
n00b


Joined: 03 Jan 2004
Posts: 66

PostPosted: Fri Apr 06, 2007 1:16 am    Post subject: rsnapshot won't actually back anything up Reply with quote

I've just gotten my new whoppin' big external drive, which I plan on using for backups. I've heard about rsnapshot and it seems terribly wonderful for managing backups. So I emerged it and set it up. I'm using this config:

Code:
$ grep -v '^#' /etc/rsnapshot.conf | grep -v '^$'
config_version  1.2
snapshot_root   /mnt/usb/snapshots/
no_create_root  1
cmd_cp          /bin/cp
cmd_rm          /bin/rm
cmd_rsync       /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_du          /bin/du
cmd_rsnapshot_diff      /usr/bin/rsnapshot-diff
interval        hourly  4
interval        daily   7
interval        weekly  52
verbose         5
loglevel        3
lockfile        /var/run/rsnapshot.pid
rsync_short_args        -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded
ssh_args        -p 4242
exclude /dev
exclude /mnt
exclude /proc
exclude /service
exclude /sys
exclude /tmp
exclude /usr/portage/
exclude /var/cache/
exclude /var/run/
exclude /var/lib/slocate/
exclude nagios.cmd
exclude socket
exclude lock
link_dest       0
sync_first      1
use_lazy_deletes        1
backup  /etc/           paranoid/


But, when I run it (note, maximum verbosity level):
Code:
$ sudo rsnapshot hourly
require Lchown
Lchown module loaded successfully
Setting locale to POSIX "C"
echo 22519 > /var/run/rsnapshot.pid
/bin/cp -al /mnt/usb/snapshots/hourly.0 /mnt/usb/snapshots/.sync
----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these options:
/usr/bin/rsnapshot hourly
----------------------------------------------------------------------------
ERROR: gnu_cp_al() needs a valid directory as an argument
ERROR: Error! cp_al("/mnt/usb/snapshots/hourly.0", "/mnt/usb/snapshots/.sync")
rm -f /var/run/rsnapshot.pid


What, it wants the directories to exist ahead of time? Ok ...
Code:
$ for foo in `seq 0 3`; do sudo mkdir /mnt/usb/snapshots/hourly.$foo; done
21:14:47 paranoid ~ $ sudo rsnapshot hourly                                     require Lchown
Lchown module loaded successfully
Setting locale to POSIX "C"
echo 4399 > /var/run/rsnapshot.pid
/bin/cp -al /mnt/usb/snapshots/hourly.0 /mnt/usb/snapshots/.sync
mv /mnt/usb/snapshots/hourly.3/ /mnt/usb/snapshots/hourly.delete/
mv /mnt/usb/snapshots/hourly.2/ /mnt/usb/snapshots/hourly.3/
mv /mnt/usb/snapshots/hourly.1/ /mnt/usb/snapshots/hourly.2/
mv /mnt/usb/snapshots/hourly.0/ /mnt/usb/snapshots/hourly.1/
/bin/cp -al /mnt/usb/snapshots/.sync /mnt/usb/snapshots/hourly.0
rm -f /var/run/rsnapshot.pid
/bin/rm -rf /mnt/usb/snapshots/hourly.delete/


Now it runs. No errors. But no backup, either.
Code:
$ find /mnt/usb/snapshots/
/mnt/usb/snapshots/
/mnt/usb/snapshots/hourly.1
/mnt/usb/snapshots/hourly.2
/mnt/usb/snapshots/hourly.3
/mnt/usb/snapshots/hourly.0
/mnt/usb/snapshots/.sync


What have I done wrong?
Back to top
View user's profile Send private message
IQgryn
l33t
l33t


Joined: 05 Sep 2005
Posts: 764
Location: WI, USA

PostPosted: Fri Apr 06, 2007 8:06 pm    Post subject: Re: rsnapshot won't actually back anything up Reply with quote

arantius wrote:
I've just gotten my new whoppin' big external drive, which I plan on using for backups. I've heard about rsnapshot and it seems terribly wonderful for managing backups. So I emerged it and set it up. I'm using this config:

Code:
$ grep -v '^#' /etc/rsnapshot.conf | grep -v '^$'
...
link_dest       0
sync_first      1
use_lazy_deletes        1
backup  /etc/           paranoid/


What have I done wrong?


The sync_first line set to 1 (a good thing, btw) means that you have to run
Code:
rsnapshot sync
before you run
Code:
rsnapshot hourly
.

Another (unrelated) thing is that you should set link_dest to 1. Linux's rsync supports it, and it supports backing up special files better. It should work either way, though.

I'll include the script that I use to actually run rsnapshot (cron calls this script every two hours on my machine) here:
Code:
#!/bin/bash

function run_rsnapshot {
   $NICE_COMMAND rsnapshot $1
}

function log_error {
   echo $1 >> /root/dead.letter
}

PID_FILE="/var/run/rsnapshot.pid"
if [[ -f $PID_FILE ]] && [[ -d "/proc/`cat $PID_FILE`" ]] && grep rsnapshot "/proc/`cat $PID_FILE`/cmdline"
then
   log_error "Error: rsnapshot already running at `date`"
   exit 0
fi

daily=false
monthly=false
yearly=false
if [[ `date +%k` -eq 0 ]]
then
   daily=true
   if [[ `date +%d` -eq 1 ]]
   then
      monthly=true
   fi
   if [[ `date +%j` -eq 1 ]]
   then
      yearly=true
   fi
fi

run_rsnapshot sync
if [[ $? -ne 0 && $? -ne 2 ]]
then
   log_error "Sync failed at `date`"
   exit 1
fi

run_rsnapshot hourly
if [[ $? -ne 0 ]]
then
   log_error "Hourly failed at `date`"
   exit 2
fi

if $daily
then
   run_rsnapshot daily
   if [[ $? -ne 0 ]]
   then
      log_error "Daily failed at `date`"
      exit 3
   fi
fi

if $monthly
then
   run_rsnapshot monthly
   if [[ $? -ne 0 ]]
   then
      log_error "Monthly failed at `date`"
      exit 4
   fi
fi

if $yearly
then
   run_rsnapshot yearly
   if [[ $? -ne 0 ]]
   then
      log_error "Yearly failed at `date`"
      exit 5
   fi
fi


There are a few tricks that I've learned, like "rsnapshot sync" returning 2 means that it actually worked. I can post my rsnapshot.conf if you'd like, too.
Back to top
View user's profile Send private message
arantius
n00b
n00b


Joined: 03 Jan 2004
Posts: 66

PostPosted: Sat Apr 07, 2007 2:50 am    Post subject: Reply with quote

So simple! Yes, I caught link_dest after I posted but not sync_first. Thanks, that script also seems very nice!
Back to top
View user's profile Send private message
IQgryn
l33t
l33t


Joined: 05 Sep 2005
Posts: 764
Location: WI, USA

PostPosted: Sun Apr 08, 2007 6:32 am    Post subject: Reply with quote

No problem; I'm glad I could help. Please add "[SOLVED]" to the subject of your first post if you're all set.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum