LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-21-2015, 05:34 PM   #1
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Rep: Reputation: 32
Quick Rsync Question, Recursion.


Hello,

have experimented with rsync a long time ago and have just returned to it for backups. It occurred to me that it is possible, unless rsync is 'smart' somehow, to recursively copy it's own backup.

I mean for instance if I want to backup the whole drive, sda1, to say sdb1 and I have a mount point for the backup such as /mnt/sda_sdb_backup. When the rsync gets to the /mnt/sda_sdb_backup dir would it just recursively copy itself to sdb1??? So on sdb you would end up with two copies, one on / (root) and one on /mnt (if it was big enough, or you would end up filling the drive and rsync would exit with an error). Or is rsync smarter than that? Last time I seem to recall adding /mnt to the exclude list.

Thanks, BashTin.
 
Old 05-21-2015, 05:46 PM   #2
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,902

Rep: Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052
Rsync has an exclude option where you enter directory or file names and it skips those areas of your hard drive:

rsync man page:

Quote:
--exclude=PATTERN exclude files matching PATTERN
The first search result I found on duckduckgo.com for "exclude directory rsync backup" was:

http://articles.slicehost.com/2007/1...es-and-folders

Hope that helps.
 
Old 05-21-2015, 06:00 PM   #3
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Original Poster
Rep: Reputation: 32
Wink

Quote:
Originally Posted by mralk3 View Post
Rsync has an exclude option where you enter directory or file names and it skips those areas of your hard drive:

rsync man page:



The first search result I found on duckduckgo.com for "exclude directory rsync backup" was:

http://articles.slicehost.com/2007/1...es-and-folders

Hope that helps.

Thank you, I know that

Quote:
Last time I seem to recall adding /mnt to the exclude list.

What I guess I mean is is the exclude necessary or is rsync smart enough to know it is copying it's own backup?
 
Old 05-21-2015, 06:04 PM   #4
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,902

Rep: Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052Reputation: 1052
As far as I know you need to exclude and rsync is not smart enough to do that automatically. Everything I have found by searching the web points to rsync not having that functionality.
 
Old 05-21-2015, 06:19 PM   #5
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,339

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by BashTin View Post
Thank you, I know that




What I guess I mean is is the exclude necessary or is rsync smart enough to know it is copying it's own backup?
rsync does not know when it is in a recursion loop. You have to exclude the backup directory from the rsync backup.

--------------------
Steve Stites
 
Old 05-21-2015, 11:45 PM   #6
aaazen
Member
 
Registered: Dec 2009
Posts: 358

Rep: Reputation: Disabled
Quote:
Originally Posted by BashTin View Post
Hello,

have experimented with rsync a long time ago and have just returned to it for backups. It occurred to me that it is possible, unless rsync is 'smart' somehow, to recursively copy it's own backup.

I mean for instance if I want to backup the whole drive, sda1, to say sdb1 and I have a mount point for the backup such as /mnt/sda_sdb_backup. When the rsync gets to the /mnt/sda_sdb_backup dir would it just recursively copy itself to sdb1??? So on sdb you would end up with two copies, one on / (root) and one on /mnt (if it was big enough, or you would end up filling the drive and rsync would exit with an error). Or is rsync smarter than that? Last time I seem to recall adding /mnt to the exclude list.

Thanks, BashTin.
Besides using the '--exclude=/mnt/*' option there is also the 'x' option which limits the rsync source to a single file system.

Here is an example of copying the root file system to a file system mounted on /a14:
Code:
#cd /
#/usr/bin/rsync -axHAX --delete --numeric-ids \
           '--exclude=/lost+found/' \
           '--exclude=/proc/*' '--exclude=/sys/*' \
           '--exclude=/tmp/*'  '--exclude=/var/tmp/*' . /a14
 
Old 05-22-2015, 06:30 AM   #7
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Original Poster
Rep: Reputation: 32
Thanks for the replies. Just wanted it clarified with people who are more knowledgeable.

comet.berkeley thanks for that. Will look into the x option as I don't want it copying the /boot partition over either, it might just be what is needed. /boot is in my exclude list but this is an interesting alternative.

BashTin.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to rsync certain filename - quick question mpc8250 Linux - Newbie 5 01-24-2013 02:31 PM
My quick and dirty rsync backup solution . . . Lufbery Slackware 13 09-18-2011 08:22 AM
LXer: Quick and Dirty Backups with rsync LXer Syndicated Linux News 0 03-09-2010 11:40 PM
quick rsync question don_wombat_73 Linux - Software 1 07-16-2008 04:18 PM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 02:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration