Subscribe to Mailing Lists     FAQFAQ    SearchSearch      Register  Log in to check your private messagesLog in to check your private messages    Log inLog in 
These forums brought to you by Backup Central, where we also have the Mr. Backup Blog, Mailing Lists, FAQs,
and Directories of Backup Software and Hardware
locking the rdiff-backup destination

 
Post new topic   Reply to topic    Backup Central Forums Forum Index -> Rdiff-Backup
View previous topic :: View next topic  
Author Message
Alex Samad
Guest





PostPosted: Wed Dec 16, 2009 7:10 pm    Post subject: locking the rdiff-backup destination Reply with quote

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
Back to top
Jakob Unterwurzacher
Guest





PostPosted: Tue Dec 22, 2009 2:14 am    Post subject: locking the rdiff-backup destination Reply with quote

Alex Samad schrieb:
Quote:
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

Quote:


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
Back to top
Alex Samad
Guest





PostPosted: Wed Dec 23, 2009 1:08 pm    Post subject: locking the rdiff-backup destination Reply with quote

On Tue, Dec 22, 2009 at 11:13:44AM +0100, Jakob Unterwurzacher wrote:
Quote:
Alex Samad schrieb:
Quote:
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.



Quote:

Jakob

Quote:


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
Back to top
Jakob Unterwurzacher
Guest





PostPosted: Wed Dec 23, 2009 5:39 pm    Post subject: locking the rdiff-backup destination Reply with quote

Am 2009-12-23 22:06, schrieb Alex Samad:
Quote:
On Tue, Dec 22, 2009 at 11:13:44AM +0100, Jakob Unterwurzacher wrote:
Quote:
Alex Samad schrieb:
Quote:
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
Back to top
Alex Samad
Guest





PostPosted: Wed Dec 23, 2009 9:51 pm    Post subject: locking the rdiff-backup destination Reply with quote

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


[snip]

Quote:

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
Back to top
Dominic Raferd
Guest





PostPosted: Thu Dec 24, 2009 2:07 am    Post subject: locking the rdiff-backup destination Reply with quote

Jakob Unterwurzacher wrote:
Quote:
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
Back to top
Jakob Unterwurzacher
Guest





PostPosted: Thu Dec 24, 2009 2:36 am    Post subject: locking the rdiff-backup destination Reply with quote

Am 2009-12-24 06:50, schrieb Alex Samad:
Quote:
Quote:

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:

Quote:
$ strace rdiff-backup /usr/sbin /tmp/des
[...]
Quote:
open("/tmp/des/rdiff-backup-data/current_mirror.2009-12-24T10:50:52+01:00.data", O_RDONLY|O_LARGEFILE) = 4
[...]
Quote:
read(4, "PID 9157\n", 4096) = 9
[...]
Quote:
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Backup Central Forums Forum Index -> Rdiff-Backup All times are GMT - 8 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group
Magic SEO URL for phpBB