0

I'm trying to make snapshot backups of my user using rsync, the base user folder has a ton of hidden files and configurations that I'm not interested in backing up, however I am interested in the hidden folders inside of it's subdirectories.

Here is the layout

Source Directory
/Base
    .ignore
    .ignore2
    .ignore3
    /dir1
        .keep
        normalfiles
    /dir2
        .keep
        normalfiles

Desired Backup Directory
/Backup
    /dir1
        .keep
        normalfiles
    /dir2
        .keep
        normalfiles

How can I ignore the first hidden files AND directories while preserving them in the subdirectories.

Solution

rsync -vrn --exclude="/.*" base/ base2/

By specifying the / before the file match /.* I managed to achieve what I was after. I have found this to be pretty useful when making snapshot backups of some mac's in my house. They tend to store tons of config information in the root folder for each user that isn't needed for my backups.

The hidden files for my own project configs and rc's is saved though since they aren't stored in the root directory.

Community
  • 1
  • 1
Duncan
  • 226
  • 1
  • 11

1 Answers1

1

I can not found "hidden folders inside of it's subdirectories" in your Code sample. Do you mean hidden files?

Here is a try:

rsync -nrv --include="/*/" --include="*/.*" --exclude="*" Base/ Base2/

-n simulate -r recursive -v verbose

Zack
  • 51
  • 1
  • 5
  • Still preserves the hidden files in the root folder. I've updated my original question description with a sample out put and made it a bit easier to read. – Duncan Mar 26 '17 at 01:47
  • Ah ok, i got it now. u want the normal files too. I like ur short update-sample – Zack Mar 26 '17 at 12:15
  • Yeah thanks, the -n flag was helpful too, I didn't even think to dry run my testing that saved me a lot of time. Thanks. – Duncan Mar 27 '17 at 01:06