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.

4
  • 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/" Jan 14, 2020 at 13:23
  • This does not work. If you exclude "AppData" it won't enter the folder.
    – zomega
    Jan 16, 2020 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/" Jan 16, 2020 at 10:00
  • No, it's still not working (same cause).
    – zomega
    Jun 13, 2020 at 12:04

3 Answers 3

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.

3
  • It does not work. It includes AppData/Local for example.
    – zomega
    Jul 9, 2020 at 8:38
  • I did not use --prune-empty-dirs. Did not know this is necessary...
    – zomega
    Jul 9, 2020 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, 2020 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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .