2017-06-06 22:06:36 +00:00
|
|
|
.. include:: create.rst.inc
|
|
|
|
|
|
|
|
Examples
|
|
|
|
~~~~~~~~
|
|
|
|
::
|
|
|
|
|
|
|
|
# Backup ~/Documents into an archive named "my-documents"
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create my-documents ~/Documents
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# same, but list all files as we process them
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --list my-documents ~/Documents
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Backup ~/Documents and ~/src but exclude pyc files
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create my-files \
|
2017-06-06 22:06:36 +00:00
|
|
|
~/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.)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create my-files /home --exclude 'sh:home/*/.thumbnails'
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# 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)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create -C zlib,6 --one-file-system root-{now:%Y-%m-%d} /
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2022-06-23 23:19:19 +00:00
|
|
|
# Backup into an archive name like FQDN-root-TIMESTAMP
|
|
|
|
$ borg create '{fqdn}-root-{now}' /
|
2019-08-09 20:46:57 +00:00
|
|
|
|
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
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create example.com-root-{now:%Y-%m-%d} .
|
2017-06-06 22:06:36 +00:00
|
|
|
$ 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
|
2022-08-01 21:47:26 +00:00
|
|
|
# docs - same parameters as borg < 1.0):
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --chunker-params buzhash,10,23,16,4095 small /smallstuff
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Backup a raw device (must not be active/in use/mounted at that time)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --read-special --chunker-params fixed,4194304 my-sdx /dev/sdX
|
2020-12-10 23:34:11 +00:00
|
|
|
|
|
|
|
# Backup a sparse disk image (must not be active/in use/mounted at that time)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --sparse --chunker-params fixed,4194304 my-disk my-disk.raw
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# No compression (none)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --compression none arch ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# Super fast, low compression (lz4, default)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create 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)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --compression zlib,N arch ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 02:28:35 +00:00
|
|
|
# Even slower, even higher compression (lzma, N = 0..9)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --compression lzma,N arch ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
2017-09-21 12:00:50 +00:00
|
|
|
# Only compress compressible data with lzma,N (N = 0..9)
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --compression auto,lzma,N arch ~
|
2017-09-21 12:00:50 +00:00
|
|
|
|
2017-06-06 22:06:36 +00:00
|
|
|
# Use short hostname, user name and current time in archive name
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create '{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
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S}' ~
|
2017-06-06 22:06:36 +00:00
|
|
|
# As above, but add nanoseconds
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f}' ~
|
2017-06-06 22:06:36 +00:00
|
|
|
|
|
|
|
# Backing up relative paths by moving into the correct directory first
|
|
|
|
$ cd /home/user/Documents
|
|
|
|
# The root directory of the archive will be "projectA"
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create '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
|
2022-06-23 23:19:19 +00:00
|
|
|
$ find ~ -size -1000k | borg create --paths-from-stdin small-files-only
|
2021-01-26 23:15:14 +00:00
|
|
|
# Use --paths-from-command with find to only backup files from a given user
|
2022-06-23 23:19:19 +00:00
|
|
|
$ borg create --paths-from-command joes-files -- find /srv/samba/shared -user joe
|
2021-01-26 23:15:14 +00:00
|
|
|
# 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" \
|
2022-06-23 23:19:19 +00:00
|
|
|
smallfiles-handle-newline
|
2022-07-04 22:38:37 +00:00
|
|
|
|