LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2022, 09:02 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Rep: Reputation: 12
Learning rsync - trouble with --exclude


Since 'luckybackup is on the way out at least with Ubuntu 20.04 I am just trying to learn about rsnyc.

Sample from luckybackup:

Code:
rsync -h --progress --stats -r -tgo -p -l -D --update --delete-after --delete-excluded
 --exclude=**/*tmp*/ 
 --exclude=**/*cache*/ 
 --exclude=**/*Cache*/ 
 --exclude=**~ 
 --exclude=/mnt/*/** 
 --exclude=/media/*/**
 --exclude=**/lost+found*/ 
 --exclude=/var/run/** 
 --exclude=/run/** 
 --exclude=/proc/** 
 --exclude=/dev/** 
 --exclude=/sys/** 
 --exclude=**/*Trash*/ 
 --exclude=**/*trash*/ 
 --exclude=**/.gvfs/ 
 /home/rick 
 /media/rick/2TB-HardDrive/E6510-20.04/home/rick/
Question, are the / */, /**, **/ symbols regex or something that luckybackup uses?? What do they mean?

I don't find anything like this in 'man regex' or other documentation I have been able to find.

My first attempt is this:

Code:
rsync -av -n --exclude Dbmysql/jquery --exclude Dbmysql/js --exclude Dbmysql/jquery-ui DBases rsyncDir
which works.
I also tried using:
--exclude {' Dbmysql/jquery', ' Dbmysql/js', 'Dbmysql/jquery-ui'} as given as a example on an internet site but doesn't work.
I also tried using --exclude-from='rsyncExclude.txt' which contains
Dbmysql/jquery
DBmysql/js
Dbmysql/jquery-ui
and does not work.

I havn't found any site to learn the correct syntax here so need help. hopefully with example.

Thanks R

Last edited by pizzipie; 03-05-2022 at 09:07 PM.
 
Old 03-05-2022, 09:13 PM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
There is explanation and examples in the rsync man page.
 
Old 03-05-2022, 10:20 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
The --exclude targets are better off inside quotes so that the shell does not process them first. I've found the --filter option easier in some context. But as mentioned already, check the manual page. It has the authoritative descriptions for both.
 
1 members found this post helpful.
Old 03-06-2022, 06:27 PM   #4
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Original Poster
Rep: Reputation: 12
RSYNC - can't get --exclude to work properly

OK, I'll start over.

Please someone, tell me what --exclude=**/*trash*/ means?

(This is an excerpt from Luckybackup rsync code in association with other code that worked properly in creating a backup file.)

Thanks,
R
 
Old 03-06-2022, 06:59 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by pizzipie View Post
OK, I'll start over.

Please someone, tell me what --exclude=**/*trash*/ means?
It specifies that files matching that rule should be ignored. You can understand exactly what that rule does by checking the rsync man page.
The "INCLUDE/EXCLUDE PATTERN RULES" section of the rsync man page is:
Code:
       o      if the pattern ends with a / then it will only match a directory, not a regular file, symlink, or device.

       o      rsync chooses between doing a simple string match and wildcard matching by checking if the pattern contains one of these three wildcard characters: '*', '?', and '[' .

       o      a '*' matches any path component, but it stops at slashes.

       o      use '**' to match anything, including slashes.
Evo2.
 
Old 03-06-2022, 07:18 PM   #6
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,689
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
it means that any path with any number of parent directories with the last directory having the string "trash" in its name, will be excluded from being copied. if that directory already exists at the destination and appropriate ownership and permission exist (or remote rsync is running with effective root credentials) the non-directory objects in that *trash* directory will not be excluded (by this --exclude).

what are you wanting to accomplish?

if you want to exclude both a directory and file objects in it, you will need two excludes. i do this in bash like this:
Code:
--exclude='**'/${dirname}{,/'*'}
 
1 members found this post helpful.
Old 03-06-2022, 07:28 PM   #7
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,689
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
i always put, at least, the * inside quotes. in bash, if you are quoting the asterisks alone, you can use either single or double quotes.
 
Old 03-06-2022, 08:40 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Please post your thread in only once in one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. Your two threads for this question have been merged into this one.
 
  


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] tar with --exclude and/or --exclude-from vbekker Linux - Newbie 6 12-09-2010 02:51 AM
Can we use exclude option in"rm" command to exclude some files/folders? yadav_rk727 Linux - Newbie 1 02-03-2010 10:14 AM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 12:36 AM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 07:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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