You are not logged in.

#1 2010-09-05 12:29:07

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

"failsafe" data copy/move tool?

before I write a shellscript myself, I was wondering if the following already exists:

a file/directory copying/moving tool (which preserves permissions, can copy directories recursively, etc), but:
1) if dest already exists, rename it first so that there is always a backup of whatever was there before.
2) if anything fails, I don't want src or dest in a bad shape.  Either they have the correct data, or they don't. (although I wouldn't mind having dest.tmp or something so that I can resume the transfer later)
3) support copying on the same host, but also to remote hosts (over scp).

afaict, neither of scp and rsync support all this.

So i guess you could call this a "transactional" copy/move. Implementation wise, here's how I would do it:
1) if dest exists, mv dest dest.old<date>
2A) in case it's a move where src and dest are on the same filesystem, mv src dest
2B) all other cases: copy all data to dest.temp, and when that worked perfectly, mv dest.temp to dest
3) remove src if needed.

Last edited by Dieter@be (2010-09-05 15:32:23)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#2 2010-09-05 18:45:44

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: "failsafe" data copy/move tool?

I think mmv do that and is in aur.

Last edited by kgas (2010-09-05 18:49:21)

Offline

#3 2010-09-05 19:04:32

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: "failsafe" data copy/move tool?

it doesn't seem to support sending to remote hosts.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#4 2010-09-05 22:43:44

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: "failsafe" data copy/move tool?

Dieter@be wrote:

it doesn't seem to support sending to remote hosts.

sshfs might take care of that?


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2010-09-06 12:24:52

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: "failsafe" data copy/move tool?

Mr.Elendig wrote:
Dieter@be wrote:

it doesn't seem to support sending to remote hosts.

sshfs might take care of that?

Meh, I prefer just running a tool


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#6 2010-09-13 04:22:04

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: "failsafe" data copy/move tool?

another one to try is unison tho' it won't fulfill all your needs.

Offline

#7 2010-09-13 21:27:28

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: "failsafe" data copy/move tool?

I would say that rsync kind of does what you want with '-a --partial-dir=DIR --delete-after --partial'.

I use -a (which is equivalent to -rlptgoD) but you can use more or less switches, for me -a seems to work fine. However I never tried using '--partial-dir=DIR --delete-after' so I don't know how well it will work. The switch --delay-updates might also interest you as it will try to make changes more atomic.

Edit:
After re-re-reading the man page I have noticed that you may also want to look at the -b and --suffix=SUFFIX switches. If rsync does what you want, it will require a ton of switches, but I guess it's better than writing and debugging your own script.

Last edited by R00KIE (2010-09-13 21:41:22)


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#8 2010-09-16 10:24:23

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: "failsafe" data copy/move tool?

Thanks R00KIE,  I'll need to investigate rsync further.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

Board footer

Powered by FluxBB