3

I want to backup my Windows home directory using cygwin and rsync:

rsync.exe -vrt --delete --exclude=AppData "/cygdrive/C/Users/user1/" "/cygdrive/D/backup/"

As you can see I excluded the AppData directory.

Is it possible to include my Firefox bookmarks in the following path?

AppData/Roaming/Mozilla/Firefox/Profiles/*/places.sqlite

The asterisk stands for a the profile name. It's not known because Firefox generates random names there.

Maybe it's possible using an exclude script with --exclude-from?

I know it's possible to copy the places.sqlite to another folder using power shell and then backup this folder.

But maybe it's possible directly with rsync.

  • Have you tried explicitally including your Firefox bookmarks? rsync.exe -vrptlH --delete --exclude=AppData --include=AppData/Roaming/Mozilla/Firefox/Profile/*/places.sqlite "/cygdrive/C/Users/user1/" "/cygdrive/D/backup/" – Paulo Tomé Jan 14 at 13:23
  • This does not work. If you exclude "AppData" it won't enter the folder. – somega Jan 16 at 9:42
  • Try adding a trailing / at the end of include pattern and it'll work: rsync.exe -vrptlH --delete --exclude=AppData/ --include=AppData/Roaming/Mozilla/Firefox/Profile/*/places.sqlite/ "/cygdrive/C/Users/user1/" "/cygdrive/D/backup/" – Paulo Tomé Jan 16 at 10:00
  • No, it's still not working (same cause). – somega Jun 13 at 12:04
4
+25

This is pretty much a duplicate of rsync: Use filters to exclude top-level directory but include some of its subdirectories.

You need to include the AppData folder tree for searching to that you can find places.sqlite, but exclude everything except that file.

rsync --dry-run -av --prune-empty-dirs \
    --include '/AppData/Roaming/Mozilla/Firefox/Profiles/*/places.sqlite' \
    --include '*/' \
    --exclude '/AppData/***' \
    '/cygdrive/C/Users/user1/' '/cygdrive/D/backup/'

The --prune-empty-dirs stops the destination being filled with directories that would otherwise remain empty, so that rsync creates only the directories it needs to hold the files it's copying. (It's a little strange that this isn't the default action, but it isn't.)

On my system, places.sqlite was under Profiles/* rather than Profile/* so I've adjusted my suggested command accordingly. As you might expect, remove --dry-run when you're happy with the result.

| improve this answer | |
  • It does not work. It includes AppData/Local for example. – somega Jul 9 at 8:38
  • I did not use --prune-empty-dirs. Did not know this is necessary... – somega Jul 9 at 9:42
  • @somega if this answer (or the other one) worked for you, please accept it with the tick mark beside the voting buttons – roaima Jul 13 at 21:34
1

here is another decision, to make symlinks: move places.sqlite to somewhere in rsync include range, like c:\places\*\places.sqlite

mklink c:\places\*\places.sqlite AppData\Roaming\Mozilla\Firefox\Profile\*\places.sqlite

or even for directory, with syntax:

mklink /d <Link> <Target>

in result, rsync will copy all needed data, and skip other.

| improve this answer | |
0

First create a include.txt file with this content:

+ AppData/Roaming
+ AppData/Roaming/Mozilla
+ AppData/Roaming/Mozilla/Firefox
+ AppData/Roaming/Mozilla/Firefox/Profiles
+ AppData/Roaming/Mozilla/Firefox/Profiles/*/places.sqlite
- AppData/*
- AppData/Roaming/*
- AppData/Roaming/Mozilla/*
- AppData/Roaming/Mozilla/Firefox/*
- AppData/Roaming/Mozilla/Firefox/Profiles/*/*

Then use it in rsync with the parameter --include-from=include.txt

This solution does not need --prune-empty-dirs so you can also backup empty directories. Also there's no need to create a link.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.