2017-06-06 22:06:36 +00:00
|
|
|
.. include:: create.rst.inc
|
|
|
|
|
|
|
|
Examples
|
|
|
|
~~~~~~~~
|
|
|
|
::
|
|
|
|
|
|
|
|
# Backup ~/Documents into an archive named "my-documents"
|
|
|
|
$ borg create /path/to/repo::my-documents ~/Documents
|
|
|
|
|
|
|
|
# same, but list all files as we process them
|
|
|
|
$ borg create --list /path/to/repo::my-documents ~/Documents
|
|
|
|
|
|
|
|
# Backup ~/Documents and ~/src but exclude pyc files
|
|
|
|
$ borg create /path/to/repo::my-files \
|
|
|
|
~/Documents \
|
|
|
|
~/src \
|
|
|
|
--exclude '*.pyc'
|
|
|
|
|
2017-06-10 10:06:18 +00:00
|
|
|
# Backup home directories excluding image thumbnails (i.e. only
|
|
|
|
# /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
|
2017-06-06 22:06:36 +00:00
|
|
|
$ borg create /path/to/repo::my-files /home \
|
|
|
|
--exclude 'sh:/home/*/.thumbnails'
|
|
|
|
|
|
|
|
# Backup the root filesystem into an archive named "root-YYYY-MM-DD"
|
|
|
|
# use zlib compression (good, but slow) - default is lz4 (fast, low compression ratio)
|
2017-11-25 18:29:34 +00:00
|
|
|
$ borg create -C zlib,6 --one-file-system /path/to/repo::root-{now:%Y-%m-%d} /
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2019-08-09 20:46:57 +00:00
|
|
|
# Backup onto a remote host ("push" style) via ssh to port 2222,
|
|
|
|
# logging in as user "borg" and storing into /path/to/repo
|
|
|
|
$ borg create ssh://borg@backup.example.org:2222/path/to/repo::{fqdn}-root-{now} /
|
|
|
|
|
2017-06-06 22:06:36 +00:00
|
|
|
# Backup a remote host locally ("pull" style) using sshfs
|
|
|
|
$ mkdir sshfs-mount
|
|
|
|
$ sshfs root@example.com:/ sshfs-mount
|
|
|
|
$ cd sshfs-mount
|
|
|
|
$ borg create /path/to/repo::example.com-root-{now:%Y-%m-%d} .
|
|
|
|
$ cd ..
|
|
|
|
$ fusermount -u sshfs-mount
|
|
|
|
|
|
|
|
# Make a big effort in fine granular deduplication (big chunk management
|
|
|
|
# overhead, needs a lot of RAM and disk space, see formula in internals
|
|
|
|
# docs - same parameters as borg < 1.0 or attic):
|
2019-02-13 05:30:13 +00:00
|
|
|
$ borg create --chunker-params buzhash,10,23,16,4095 /path/to/repo::small /smallstuff
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Backup a raw device (must not be active/in use/mounted at that time)
|
2020-12-10 23:34:11 +00:00
|
|
|
$ borg create --read-special --chunker-params fixed,4194304 /path/to/repo::my-sdx /dev/sdX
|
|
|
|
|
|
|
|
# Backup a sparse disk image (must not be active/in use/mounted at that time)
|
|
|
|
$ borg create --sparse --chunker-params fixed,4194304 /path/to/repo::my-disk my-disk.raw
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# No compression (none)
|
2017-09-21 02:26:52 +00:00
|
|
|
$ borg create --compression none /path/to/repo::arch ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# Super fast, low compression (lz4, default)
|
2017-09-21 02:26:52 +00:00
|
|
|
$ borg create /path/to/repo::arch ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# Less fast, higher compression (zlib, N = 0..9)
|
2017-06-06 22:06:36 +00:00
|
|
|
$ borg create --compression zlib,N /path/to/repo::arch ~
|
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# Even slower, even higher compression (lzma, N = 0..9)
|
2017-06-06 22:06:36 +00:00
|
|
|
$ borg create --compression lzma,N /path/to/repo::arch ~
|
|
|
|
|
2017-09-21 12:00:50 +00:00
|
|
|
# Only compress compressible data with lzma,N (N = 0..9)
|
|
|
|
$ borg create --compression auto,lzma,N /path/to/repo::arch ~
|
|
|
|
|
2017-06-06 22:06:36 +00:00
|
|
|
# Use short hostname, user name and current time in archive name
|
|
|
|
$ borg create /path/to/repo::{hostname}-{user}-{now} ~
|
2019-07-16 02:53:30 +00:00
|
|
|
# Similar, use the same datetime format that is default as of borg 1.1
|
2017-06-06 22:06:36 +00:00
|
|
|
$ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S} ~
|
|
|
|
# As above, but add nanoseconds
|
|
|
|
$ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f} ~
|
|
|
|
|
|
|
|
# Backing up relative paths by moving into the correct directory first
|
|
|
|
$ cd /home/user/Documents
|
|
|
|
# The root directory of the archive will be "projectA"
|
2017-06-07 14:29:37 +00:00
|
|
|
$ borg create /path/to/repo::daily-projectA-{now:%Y-%m-%d} projectA
|
2021-01-26 23:15:14 +00:00
|
|
|
|
|
|
|
# Use external command to determine files to archive
|
|
|
|
# Use --paths-from-stdin with find to only backup files less than 1MB in size
|
|
|
|
$ find ~ -size -1000k | borg create --paths-from-stdin /path/to/repo::small-files-only
|
|
|
|
# Use --paths-from-command with find to only backup files from a given user
|
|
|
|
$ borg create --paths-from-command /path/to/repo::joes-files -- find /srv/samba/shared -user joe
|
|
|
|
# Use --paths-from-stdin with --paths-delimiter (for example, for filenames with newlines in them)
|
|
|
|
$ find ~ -size -1000k -print0 | borg create \
|
|
|
|
--paths-from-stdin \
|
|
|
|
--paths-delimiter "\0" \
|
|
|
|
/path/to/repo::smallfiles-handle-newline
|