LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-16-2015, 09:39 PM   #1
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Rep: Reputation: 38
Rsync: problem with filter file


I am trying to use rsync to backup to an external drive. I am using a 'filter file' Rsync copies all the directories over under /. I only wanted 4 directories. I have looked at the filter file and backup script, but can't see the problem. I think rysnc is reading the filter file, because it is excluding the /home/joe/.cache/ file and lost+found in /home. Hoping someone will see the problem.

I have attached the files

Thanks
Attached Files
File Type: txt root-backup.txt (274 Bytes, 40 views)
File Type: txt root-filter-rule.txt (115 Bytes, 26 views)
 
Old 08-19-2015, 03:52 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If you de-dup things you're only syncing 5 directories: /root/, /boot/, /etc/, /usr/ and /home/joe/, the latter of which has an --exclude=/home/joe/.cache/ clause. So, while not being exactly what you're asking for, you could:

Code:
#!/bin/bash --
set -vx
grep -q -m1 "root-backup" /proc/mounts || exit 1
SRCS="/root/ /boot/ /etc/ /usr/ /home/joe/"
TRG="/media/root-backup/"
OPT="-nav --numeric-ids --delete --delete-excluded "

for SRC in $SRCS; do
 case $SRC in
  /home/joe/) EXCLUDES="--exclude=/home/joe/.cache/";;
           *) unset EXCLUDES;;
 esac
 rsync $OPT $SRC $TRG $EXCLUDES
done
exit 0
*Note I added a "set -vx" line so you can see the script execute with all the vars filled in (comment that line out when done debugging) and the rsync "-n" switch (remove when you're satisfied --dry-run shows no problems).
 
Old 08-29-2015, 10:38 PM   #3
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Original Poster
Rep: Reputation: 38
I found out why rsync was copying files that I didn't want over. I had a space on the last line after - /*
on the root-filter-rule.txt file.

Now I'm getting the right files transferred.

Last edited by JosephS; 08-30-2015 at 05:55 PM.
 
  


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
[SOLVED] Rsync filter schimkat Linux - Newbie 2 10-27-2010 08:04 AM
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 02:10 AM
problem transferring file permissions using rsync replica88 Linux - Software 4 02-04-2010 02:39 AM
Help with rsync filter file Meson Linux - General 1 09-29-2008 06:59 PM
Rsync - Exclude single file problem LinuxLuva Linux - Software 3 11-08-2007 09:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:01 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