1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-29 11:16:43 +00:00
borg/docs/usage/create.rst

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
3.6 KiB
ReStructuredText
Raw Normal View History

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 /mnt/disk/docs, but strip path prefix using the slashdot hack
$ borg create /path/to/repo::docs /mnt/disk/./docs
# 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'
# Backup home directories excluding image thumbnails (i.e. only
2017-06-10 10:06:18 +00:00
# /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"
2017-06-06 22:06:36 +00:00
# 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
# Backup into an archive name like FQDN-root-TIMESTAMP
2022-06-23 23:19:19 +00:00
$ borg create '{fqdn}-root-{now}' /
# Backup a remote host locally ("pull" style) using sshfs
2017-06-06 22:06:36 +00:00
$ 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 docs):
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
# 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
# No compression (none)
2022-06-23 23:19:19 +00:00
$ borg create --compression none arch ~
2017-06-06 22:06:36 +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
# 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
# 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
# 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-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}' ~
# 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
# Use external command to determine files to archive
# Use --paths-from-stdin with find to back up only 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
# Use --paths-from-command with find to back up files from only a given user
2022-06-23 23:19:19 +00:00
$ borg create --paths-from-command 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" \
2022-06-23 23:19:19 +00:00
smallfiles-handle-newline
2022-07-04 22:38:37 +00:00