Hi,
I have a bit of a tricky question about rsync.
Let's say I want to backup a bunch of configuration files with rsync, in a script.
What I don't want to do : a full snapshot of /etc. What I want to do : backup only those files I need, in an otherwise empty directory tree.
In my script, I'd begin with a list of the files I effectively want to backup. Something like :
/etc/httpd/conf/httpd.conf /etc/httpd/vhosts.d/*.conf /etc/exports
Then I'd have some other files in /usr/local/bin and /usr/local/sbin, which I would like to backup too.
Instead of a puzzling explanation, let me just show you how I would like my resulting backup to look like, so you get the idea :
etc/ `-- httpd |-- conf | `-- httpd.conf `-- vhosts.d |-- site1.conf |-- site2.conf `-- site3.conf
usr/ `-- local |-- bin | |-- script1.sh | `-- script2.sh |-- sbin |-- sbinscript3.sh `-- sbinscript4.sh
Now if I do something like this :
rsync -av /etc/httpd/conf/httpd.conf destinationfolder/
I get something like :
destinationfolder/httpd.conf
QUESTION (at last) : is there a way rsync can somehow add the full file path, so the end result is more like :
destinationfolder/etc/httpd/conf/httpd.conf ?
Any suggestions ?
Niki
On Wed, Oct 28, 2009 at 5:18 PM, Niki Kovacs contact@kikinovak.net wrote:
Hi,
I have a bit of a tricky question about rsync.
Let's say I want to backup a bunch of configuration files with rsync, in a script.
What I don't want to do : a full snapshot of /etc. What I want to do : backup only those files I need, in an otherwise empty directory tree.
In my script, I'd begin with a list of the files I effectively want to backup. Something like :
/etc/httpd/conf/httpd.conf /etc/httpd/vhosts.d/*.conf /etc/exports
Then I'd have some other files in /usr/local/bin and /usr/local/sbin, which I would like to backup too.
Instead of a puzzling explanation, let me just show you how I would like my resulting backup to look like, so you get the idea :
etc/ `-- httpd |-- conf | `-- httpd.conf `-- vhosts.d |-- site1.conf |-- site2.conf `-- site3.conf
usr/ `-- local |-- bin | |-- script1.sh | `-- script2.sh |-- sbin |-- sbinscript3.sh `-- sbinscript4.sh
Now if I do something like this :
rsync -av /etc/httpd/conf/httpd.conf destinationfolder/
I get something like :
destinationfolder/httpd.conf
QUESTION (at last) : is there a way rsync can somehow add the full file path, so the end result is more like :
destinationfolder/etc/httpd/conf/httpd.conf ?
Any suggestions ?
Niki _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi Nikki,
I don't think you can do that with rsync out of the box. You need to script your way around it. One thing I can advise is to use rdiff-backup, this one is based on rsync and can create full-paths, as well as incremental backups (e.g. you could restore a file and see how it looked 2 weeks ago). Rdiff-backup should be available from RPMForge.
Niki Kovacs wrote:
Hi,
rsync -av /etc/httpd/conf/httpd.conf destinationfolder/
I get something like :
destinationfolder/httpd.conf
This is normal because your copying a file not a tree
QUESTION (at last) : is there a way rsync can somehow add the full file path, so the end result is more like :
Copy the tree and use something like includes or excludes or even the files-from option to specifically include the files you want to copy.
e.g.
[natea@us-cfe002:/etc]$ cat /tmp/files.txt /etc/httpd/conf/httpd.conf [natea@us-cfe002:/etc]$
[natea@us-cfe002:/etc]$ rsync -av --files-from=/tmp/files.txt / /tmp/ building file list ... done etc/ etc/httpd/ etc/httpd/conf/ etc/httpd/conf/httpd.conf
sent 34853 bytes received 40 bytes 69786.00 bytes/sec total size is 34704 speedup is 0.99 [natea@us-cfe002:/etc]$ ls -ltr /tmp/etc/httpd/conf/httpd.conf -rw-r--r-- 1 natea natea 34704 Nov 18 2007 /tmp/etc/httpd/conf/httpd.conf
use the -n option with rsync for testing, to have it only show you what it would do rather than doing it.
nate
On Wed, Oct 28, 2009 at 12:18 PM, Niki Kovacs contact@kikinovak.net wrote:
Hi,
I have a bit of a tricky question about rsync.
Let's say I want to backup a bunch of configuration files with rsync, in a script.
What I don't want to do : a full snapshot of /etc. What I want to do : backup only those files I need, in an otherwise empty directory tree.
In my script, I'd begin with a list of the files I effectively want to backup. Something like :
/etc/httpd/conf/httpd.conf /etc/httpd/vhosts.d/*.conf /etc/exports
Then I'd have some other files in /usr/local/bin and /usr/local/sbin, which I would like to backup too.
Instead of a puzzling explanation, let me just show you how I would like my resulting backup to look like, so you get the idea :
etc/ `-- httpd |-- conf | `-- httpd.conf `-- vhosts.d |-- site1.conf |-- site2.conf `-- site3.conf
usr/ `-- local |-- bin | |-- script1.sh | `-- script2.sh |-- sbin |-- sbinscript3.sh `-- sbinscript4.sh
Now if I do something like this :
rsync -av /etc/httpd/conf/httpd.conf destinationfolder/
I get something like :
destinationfolder/httpd.conf
QUESTION (at last) : is there a way rsync can somehow add the full file path, so the end result is more like :
destinationfolder/etc/httpd/conf/httpd.conf ?
Here's how we do it.
cd / rsync -avR etc/httpd/conf/httpd.conf /destinationfolder
Note that the lack of leading slash on the source.
-- Jeff
From: Niki Kovacs contact@kikinovak.net
Let's say I want to backup a bunch of configuration files with rsync, in a script.
See --files-from=FILE in rsync manpage
JD
John Doe a écrit :
From: Niki Kovacs contact@kikinovak.net
Let's say I want to backup a bunch of configuration files with rsync, in a script.
See --files-from=FILE in rsync manpage
One general remark: I have one more reason to love this distro. I'm posting a message about a rather quirky rsync option at 18:18 PM. And sixteen minutes later, at 18:34, I have five competent answers with the odd hint at other interesting options to explore.
Thanks to everybody !
Niki
Niki Kovacs wrote:
rsync -av /etc/httpd/conf/httpd.conf destinationfolder/
I get something like :
destinationfolder/httpd.conf
QUESTION (at last) : is there a way rsync can somehow add the full file path, so the end result is more like :
destinationfolder/etc/httpd/conf/httpd.conf ?
Any suggestions ?
Personally, I'd run backuppc (http://backuppc.sourceforge.net/ or the epel package) and take the whole tree because (a)it will compress the files and link all duplicates so it doesn't waste that much space, (b) when you need a copy you'll have it instead of finding out it was one you didn't bother to include, and (c) it won't take you a week to set up and test.
Les Mikesell a écrit :
Personally, I'd run backuppc (http://backuppc.sourceforge.net/ or the epel package) and take the whole tree because (a)it will compress the files and link all duplicates so it doesn't waste that much space, (b) when you need a copy you'll have it instead of finding out it was one you didn't bother to include, and (c) it won't take you a week to set up and test.
OK. I just added it to my TODO-list.