A incremental full system backup solution using rsync
npm install rsync-snapshotRsync Snapshot
==============

A Node.js implementation of incremental full system backups using rsync based on rsync - Arch Linux Wiki
See Incremental Bacukps with rsync for details on environment configuration
/ (or any other folder) with permissions and other attributes preserved/ and root access on the server to be able to set correct file ownershiprsync, rm and mv from the SSH user is required. This must be manually configured on the server. See Editing /etc/sudoers for detailsnpm install -g rsync-snapshotrsync-snapshot --dst /media/MyBackuprsync-snapshot --shell ssh --dst username@myserver.com:/media/MyBackuprsync-snapshot regularlynpm install -g rsync-snapshot to update to latest version2018-02-21.19-06-26)2018-02-21.19-06-26.createdDatabase) as long as .incomplete is not appended (which is reserved for backups in progress, failed or canceled)ls -1 | sort -r can be used to sort backups (most recent to least recent)latest will always point to the most recent backup#### Parameters
Note: To wrap strings double quotes must be used. Ex: --shell "ssh -p 2222" must be used to specify ssh parameters. Single quotes will not be parsed correctly.
##### Rsync
- --src PATH Default: /*
- Source path to backup
- --dst PATH
- Destination folder path for backup
- If using --shell ssh format is username@server:destinationPath
- Folders will be created in this directory for incremental backup history
- --shell SHELL
- Remote shell to use
- Note: Remote shell is assumed to be a ssh compatible client if specified
- Ex: ssh or "ssh -p 2222"
- --exclude PATH Can be used multiple times
- Note: Unless --excludeFile is set default exclude list will be used in addition to specified excludes
- Syntax
- Include empty folder in destination: /dev/*
- Do not include folder in destination: /dev
- Glob style syntax: */steam/steamapps (Will exclude any file/folder ending with /steam/steamapps)
- See Filter Rules for more information
- --excludeFile EXCLUDEFILE Default: defaultExclude.txt
- Similar to --exclude but is passed a text file with an exclude rule per line
- For exclude rule syntax see --exclude documentation
- --checksum
- Change default transfer criteria from comparing modification date and file size to just comparing file size
- This means the file size being the same is the only requirement needed to generate a checksum and transfer potential file differences
- Enabling this flag will incur a performance penalty as many more checksums may be generated
- --accurateProgress
- Recurse all directories before transferring any files to generate a more accurate file tree
- Note: This will increase memory usage substantially (10x increase is possible)
- --noDelete
- Don't delete existing files in --dst
- --noDeleteExcludes
- Don't delete existing files in --dst that are excluded
- Can be useful for restores where excluded files are hardware specific
- --rsyncPath PATH Defaults to "sudo rsync"
- Command to execute rsync
- If using SSH "sudo rsync" is recommended however it requires additional setup as a password prompt can not be asked (/etc/sudoers file must be modified to set NOPASSWD for rsync, see Rsync over ssh without root)
- --setRsyncArg ARGUMENT=VALUE Can be used multiple times
- Specify an argument to be passed to rsync and (optionally) its value
- Ex: --setRsyncArgument checksum or --setRsyncArgument block-size=1024
- --unsetRsyncArg ARGUMENT Can be used multiple times
- Unset an argument which was already passed to rsync
##### Snapshot Management
- --maxSnapshots NUMBER
- Maximum number of snapshots
- Once number is exceeded, oldest snapshots will be deleted until the condition is met
##### Script Hooks
Script Hooks can be used to run scripts before or after backup on the client while using the same log file as the backup process. Script hooks are not run in parallel.
- --runBefore EXECUTABLE Can be used multiple times
- Script to run on client before backup (file will be executed directly and output will be logged)
- Can be useful for taking backups of data that requires consistency (ex: running pg_dump) and putting it in a folder that will be transfered by Rsync in the backup
- --runAfter EXECUTABLE Can be used multiple times
- Script to run on client after backup
- Hook will only trigger if backup is successful
- Can be useful for deleting temporary data after it is successfully transferred
##### Logging
- --logFormat FORMAT Default: text
- Format used to log output
- Supported formats:
- json - Rsync process output in JSON format
- text - An easy to read rsync process output
- raw - Output directly from rsync process
- --logFile PATH
- Path to file used to write output in logFormat
- If file already exists it will be appended, otherwise it will be created
- --logFileLevel LEVEL Default: ALL
- Level of output to write to log file
- Supported levels:
- ALL Log Progress, Warnings, Errors and Summary
- WARN Log Warnings, Errors and Summary
- ERROR Log Errors and Summary
##### Restore
- --restore
- Clone files from --src to --dst
- Note: Since there is no snapshot management done in restore mode, restores can be done from server to client or client to server by switching the destination and source arguments
- If this flag is used snapshots are not used, this flag enables a simple rsync copy from the source to destination
- All snapshot management flags will be ignored
##### Debug Info
- --version
- Print package version and exit
- --printCommand
- Print rsync command used
--checksum flagrsync warning: some files vanished before they could be transferred (code 24)file has vanishedopendir failed: Permission Deniedsend_files failed to open: Permission DeniedAn error occurred connecting to server while preparing for backup: sudo: no tty present and no askpass program specifiedsudo rm and sudo mv without a password. If this error occurs the sudoers file (on the server) needs to be modified to allow rm and mv without a password.An error occurred connecting to server whiel preparing for backup: mkdir: cannot create directory: Permission denied--dst--restore