|
NAMEborg-create - Create new archive SYNOPSISborg [common options] create [options] ARCHIVE [PATH...] DESCRIPTIONThis command creates a backup archive containing all files found while recursively traversing all paths specified. Paths are added to the archive as they are given, which means that if relative paths are desired, the command has to be run from the correct directory. The slashdot hack in paths (recursion roots) is triggered by using /./: /this/gets/stripped/./this/gets/archived means to process that filesystem object, but strip the prefix on the left side of ./ from the archived items (in this case, this/gets/archived will be the path in the archived item). When giving '-' as a path, Borg will read data from standard input and create a file 'stdin' in the created archive from that data. In some cases, it is more appropriate to use --content-from-command. See section "Reading from stdin" below for details. The archive will consume almost no disk space for files or parts of files that have already been stored in other archives. The archive name needs to be unique. It must not end in '.checkpoint' or '.checkpoint.N' (with N being a number), because these names are used for checkpoints and treated in special ways. In the archive name, you may use the following placeholders: {now}, {utcnow}, {fqdn}, {hostname}, {user} and some others. Backup speed is increased by not reprocessing files that are already part of existing archives and weren't modified. The detection of unmodified files is done by comparing multiple file metadata values with previous values kept in the files cache. This comparison can operate in different modes as given by --files-cache:
inode number: better safety, but often unstable on network file systems Normally, detecting file modifications will take inode information into consideration to improve the reliability of file change detection. This is problematic for files located on SSHFS and similar network file systems which do not provide stable inode numbers; such files will always be considered modified. You can use modes without inode in this case to improve performance, but the reliability of change detection might be reduced. ctime vs. mtime: safety vs. speed
The --files-changed option controls how Borg detects if a file has changed during backup:
The mount points of file systems or file system snapshots should be the same for every creation of a new archive to ensure fast operation. This is because the file cache that is used to determine changed files quickly uses absolute file names. If this is not possible, consider creating a bind mount to a stable location. The --progress option shows (from left to right) Original, Compressed and Deduplicated (O, C and D, respectively), then the number of files (N) processed so far, followed by the currently processed path. When using --stats, you will get some statistics about how much data was added - the "This Archive" deduplicated size there is most interesting as that is how much your repository will grow. Please note that the "All archives" stats refer to the state after creation. Also, the --stats and --dry-run options are mutually exclusive because the data is not actually compressed and deduplicated during a dry run. For more help on include/exclude patterns, see the borg_patterns command output. For more help on placeholders, see the borg_placeholders command output. OPTIONSSee borg-common(1) for common options of Borg commands. options
Include/Exclude options
Filesystem options
Archive options
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 /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 $ borg create /path/to/repo::my-files \ NOTESThe --exclude patterns are not like tar. In tar --exclude .bundler/gems will exclude foo/.bundler/gems. In borg it will not, you need to use --exclude '*/.bundler/gems' to get the same effect. In addition to using --exclude patterns, it is possible to use --exclude-if-present to specify the name of a filesystem object (e.g. a file or folder name) which, when contained within another folder, will prevent the containing folder from being backed up. By default, the containing folder and all of its contents will be omitted from the backup. If, however, you wish to only include the objects specified by --exclude-if-present in your backup, and not include any other contents of the containing folder, this can be enabled through using the --keep-exclude-tags option. The -x or --one-file-system option excludes directories that are mount points (and everything in them). It detects mount points by comparing the device number from the output of stat() of the directory and its parent directory. Specifically, it excludes directories for which stat() reports a device number different from the device number of their parent. In general: be aware that there are directories with device numbers different from their parent, which the kernel does not consider mount points, and vice versa. Linux examples for this are bind mounts (possibly same device number, but always a mount point) and all subvolumes of a Btrfs file system (different device numbers from the parent but not necessarily mount points). macOS examples are the APFS mounts of a typical macOS installation. Therefore, when using --one-file-system, you should double-check that the backup works as intended. Item flags--list outputs a list of all files, directories and other file system items it considered (no matter whether they had content changes or not). For each item, it prefixes a single-letter flag that indicates type and/or status of the item. If you are interested only in a subset of that output, you can give e.g. --filter=AME and it will only show regular files with A, M or E status (see below). A uppercase character represents the status of a regular file relative to the "files" cache (not relative to the repo -- this is an issue if the files cache is not used). Metadata is stored in any case and for 'A' and 'M' also new data chunks are stored. For 'U' all data chunks refer to already existing chunks.
A lowercase character means a file type other than a regular file, borg usually just stores their metadata:
Other flags used include:
Reading backup data from stdinThere are two methods to read from stdin. Either specify - as path and pipe directly to borg: backup-vm --id myvm --stdout | borg create REPO::ARCHIVE - Or use --content-from-command to have Borg manage the execution of the command and piping. If you do so, the first PATH argument is interpreted as command to execute and any further arguments are treated as arguments to the command: borg create --content-from-command REPO::ARCHIVE -- backup-vm --id myvm --stdout -- is used to ensure --id and --stdout are not considered arguments to borg but rather backup-vm. The difference between the two approaches is that piping to borg creates an archive even if the command piping to borg exits with a failure. In this case, one can end up with truncated output being backed up. Using --content-from-command, in contrast, borg is guaranteed to fail without creating an archive should the command fail. The command is considered failed when it returned a non-zero exit code. Reading from stdin yields just a stream of data without file metadata associated with it, and the files cache is not needed at all. So it is safe to disable it via --files-cache disabled and speed up backup creation a bit. By default, the content read from stdin is stored in a file called 'stdin'. Use --stdin-name to change the name. Feeding all file paths from externallyUsually, you give a starting path (recursion root) to borg and then borg automatically recurses, finds and backs up all fs objects contained in there (optionally considering include/exclude rules). If you need more control and you want to give every single fs object path to borg (maybe implementing your own recursion or your own rules), you can use --paths-from-stdin or --paths-from-command (with the latter, borg will fail to create an archive should the command fail). Borg supports paths with the slashdot hack to strip path prefixes here also. So, be careful not to unintentionally trigger that. SEE ALSOborg-common(1), borg-delete(1), borg-prune(1), borg-check(1), borg-patterns(1), borg-placeholders(1), borg-compression(1) AUTHORThe Borg Collective
|