(redirected from Homepage)

Strona domowa

Witam na mojej prywatnej stronie internetowej!

[If this is all Polish to you, click here: English]

Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.

Marcin ‘mbork’ Borkowski

2024-09-30 Backing up small files with Borg

I’ve been using Borg for many years now. Today, however, I had a very specific need. I needed to back up files in some directory (and its subdirectories, of course) but with the exception of “large” files. Usually I exclude files based on their names, but since I started using gocryptfs, I didn’t really know the names of the files I wanted to omit from the backup.

Borg’s manual contains an example of exactly that:

find ~ -size -1000k | borg create --paths-from-stdin /path/to/repo::small-files-only

but it didn’t work for me. The problem was simple – either you provide the list of files to back up on the command line or in stdin, but not both:

borg: error: Must not pass PATH with ``--paths-from-stdin``.

On the other hand, I needed to provide the explicit list of files and directories in my home directory to back up. What to do, then?

It turns out that there exists a simple solution. Borg create command has the --exclude and --exclude-from parameters which allow to exclude given files – either giving a list of paths (possibly using wildcards) or a file containing such list.

So, here is my solution. I used process substitution to create a “temporary filename” to pass the names of all the “big” files to Borg’s --exclude-from. Assuming that I want to back up the directory to-backup, I did this:

borg create --exclude-from <(find to-backup/ -size +100k) repository::archive to-backup/

That’s it for today, see you next time!

CategoryEnglish, CategoryBlog

Comments on this page

More...