SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
locking the rdiff-backup destination
Author Message
Post locking the rdiff-backup destination 
Hi

Is there a tool to lock the db such that rdif-backup will not use the
destination - i know rdif-backup does it.


I want to lock the db and then rsync the destination offsite and then
unlock the db.


I am also looking at doing a lvm snapshot as well.

Alex



--
"The person who runs FEMA is someone who must have the trust of the president. Because the person who runs FEMA is the first voice, often times, of someone whose life has been turned upside down hears from."

- George W. Bush
01/04/2001
Austin, TX

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
Alex Samad schrieb:
Hi

Is there a tool to lock the db such that rdif-backup will not use the
destination - i know rdif-backup does it.


I want to lock the db and then rsync the destination offsite and then
unlock the db.

With "db" you mean the rdiff-backup destination directory?

Jakob



I am also looking at doing a lvm snapshot as well.

Alex





------------------------------------------------------------------------

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki



_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
On Tue, Dec 22, 2009 at 11:13:44AM +0100, Jakob Unterwurzacher wrote:
Alex Samad schrieb:
Hi

Is there a tool to lock the db such that rdif-backup will not use the
destination - i know rdif-backup does it.


I want to lock the db and then rsync the destination offsite and then
unlock the db.

With "db" you mean the rdiff-backup destination directory?

yes, I would like to lock the rdiff-backup destination such that
rdiff-backup will not use it until after the rsync offsite has finished.




Jakob



I am also looking at doing a lvm snapshot as well.

Alex





------------------------------------------------------------------------

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki



--
"I don't want nations feeling like that they can bully ourselves and our allies. I want to have a ballistic defense system so that we can make the world more peaceful, and at the same time I want to reduce our own nuclear capacities to the level commiserate with keeping the peace."

- George W. Bush
10/23/2000
Des Moines, IA

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
Am 2009-12-23 22:06, schrieb Alex Samad:
On Tue, Dec 22, 2009 at 11:13:44AM +0100, Jakob Unterwurzacher wrote:
Alex Samad schrieb:
Hi

Is there a tool to lock the db such that rdif-backup will not use the
destination - i know rdif-backup does it.


I want to lock the db and then rsync the destination offsite and then
unlock the db.

With "db" you mean the rdiff-backup destination directory?

yes, I would like to lock the rdiff-backup destination such that
rdiff-backup will not use it until after the rsync offsite has finished.

I guess you will have to use a wrapper script for your rsync job and
your rdiff-backup job that does the locking (and obeys the lock).

If you start both jobs at the same machine, it's easy:
Put this at the start of each script - it will then exit when another
instance is running.

#####

#!/bin/bash

exec 200> /tmp/lockfileXYZ
flock -n 200 || echo 'Could not get lock!' && exit 1

#####


Jakob


_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
On Thu, Dec 24, 2009 at 02:38:23AM +0100, Jakob Unterwurzacher wrote:
Am 2009-12-23 22:06, schrieb Alex Samad:
On Tue, Dec 22, 2009 at 11:13:44AM +0100, Jakob Unterwurzacher wrote:
Alex Samad schrieb:
Hi


[snip]


I guess you will have to use a wrapper script for your rsync job and
your rdiff-backup job that does the locking (and obeys the lock).

yep doing something like that already, but I noticed that rdiff-backup
has a way of knowing when another riff-backup is running against the
dest, it would be could to be able to trigger that flag as well from
outside rdiff-backup

[snip]


_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
Jakob Unterwurzacher wrote:
I guess you will have to use a wrapper script for your rsync job and
your rdiff-backup job that does the locking (and obeys the lock).

If you start both jobs at the same machine, it's easy:
Put this at the start of each script - it will then exit when another
instance is running.

#####

#!/bin/bash

exec 200> /tmp/lockfileXYZ
flock -n 200 || echo 'Could not get lock!' && exit 1

#####
Nice tip! An alternative which doesn't require flock or a temporary lock
file is (again for a bash script):

######
#!/bin/bash

[ -n "`ps h -C rdiff-backup`" ] && echo "`basename $0` aborting -
rdiff-backup is running" && exit 1

######

Dominic


_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Post locking the rdiff-backup destination 
Am 2009-12-24 06:50, schrieb Alex Samad:

I guess you will have to use a wrapper script for your rsync job and
your rdiff-backup job that does the locking (and obeys the lock).

yep doing something like that already, but I noticed that rdiff-backup
has a way of knowing when another riff-backup is running against the
dest, it would be could to be able to trigger that flag as well from
outside rdiff-backup

Indeed. I had not noticed that.

This is what rdiff-backup does (strace) when there is another instance
running:

$ strace rdiff-backup /usr/sbin /tmp/des
[...]
open("/tmp/des/rdiff-backup-data/current_mirror.2009-12-24T10:50:52+01:00.data", O_RDONLY|O_LARGEFILE) = 4
[...]
read(4, "PID 9157\n", 4096) = 9
[...]
kill(9157, SIG_0) = 0
write(2, "Fatal Error: It appears that a p"..., 298
Fatal Error: It appears that a previous rdiff-backup session with process
id 9157 is still running. If two different rdiff-backup processes write
the same repository simultaneously, data corruption will probably
result. To proceed with regress anyway, rerun rdiff-backup with the
--force option.
) = 298

So, when you read out the PIDs from the
rdiff-backup-data/current_mirror.*
files (they contain "PID 12345"), check whether one of them is running,
and none is, then it's safe to start rsync.

Note that
$ kill -0 PID
is somewhat unsafe as a check whether PID is running. It will return 1
when the process does not exist but will also return 1 when the process
exists but you don't have the permission to send a signal to it. I'd use
ps -p.


Jakob


_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-users < at > nongnu.org
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Display posts from previous:
Reply to topic Page 1 of 1
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
  


Magic SEO URL for phpBB