{"id":13496059,"url":"https://github.com/laurent22/rsync-time-backup","last_synced_at":"2025-05-14T13:07:57.588Z","repository":{"id":1025491,"uuid":"13895467","full_name":"laurent22/rsync-time-backup","owner":"laurent22","description":"Time Machine style backup with rsync.","archived":false,"fork":false,"pushed_at":"2024-09-12T06:28:31.000Z","size":750,"stargazers_count":3486,"open_issues_count":113,"forks_count":458,"subscribers_count":103,"default_branch":"master","last_synced_at":"2025-05-12T15:54:04.638Z","etag":null,"topics":["backup","bash","rsync","shell","time-machine"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laurent22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"laurent22"}},"created_at":"2013-10-27T03:57:45.000Z","updated_at":"2025-05-10T00:14:20.000Z","dependencies_parsed_at":"2023-07-06T13:01:53.079Z","dependency_job_id":"0ed61fb8-dca1-4aa8-88f0-d1ee5e88a550","html_url":"https://github.com/laurent22/rsync-time-backup","commit_stats":{"total_commits":174,"total_committers":48,"mean_commits":3.625,"dds":0.8103448275862069,"last_synced_commit":"c859a821b86845624c1d760be1688aa2495d4a15"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laurent22%2Frsync-time-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laurent22%2Frsync-time-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laurent22%2Frsync-time-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laurent22%2Frsync-time-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laurent22","download_url":"https://codeload.github.com/laurent22/rsync-time-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149959,"owners_count":22022851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","bash","rsync","shell","time-machine"],"created_at":"2024-07-31T19:01:41.643Z","updated_at":"2025-05-14T13:07:52.577Z","avatar_url":"https://github.com/laurent22.png","language":"Shell","funding_links":["https://github.com/sponsors/laurent22"],"categories":["Shell","Install from Source","Uncategorized"],"sub_categories":["Snapshots Management/System Recovery","Uncategorized"],"readme":"# Rsync time backup\n\nThis script offers Time Machine-style backup using rsync. It creates incremental backups of files and directories to the destination of your choice. The backups are structured in a way that makes it easy to recover any file at any point in time.\n\nIt works on Linux, macOS and Windows (via WSL or Cygwin). The main advantage over Time Machine is the flexibility as it can backup from/to any filesystem and works on any platform. You can also backup, for example, to a Truecrypt drive without any problem.\n\nOn macOS, it has a few disadvantages compared to Time Machine - in particular it does not auto-start when the backup drive is plugged (though it can be achieved using a launch agent), it requires some knowledge of the command line, and no specific GUI is provided to restore files. Instead files can be restored by using any file explorer, including Finder, or the command line.\n\n## Installation\n\n\tgit clone https://github.com/laurent22/rsync-time-backup\n\n## Usage\n\n\tUsage: rsync_tmbackup.sh [OPTION]... \u003c[USER@HOST:]SOURCE\u003e \u003c[USER@HOST:]DESTINATION\u003e [exclude-pattern-file]\n\n\tOptions\n\t -p, --port             SSH port.\n\t -h, --help             Display this help message.\n\t -i, --id_rsa           Specify the private ssh key to use.\n\t --rsync-get-flags      Display the default rsync flags that are used for backup. If using remote\n\t                        drive over SSH, --compress will be added.\n\t --rsync-set-flags      Set the rsync flags that are going to be used for backup.\n\t --rsync-append-flags   Append the rsync flags that are going to be used for backup.\n\t --log-dir              Set the log file directory. If this flag is set, generated files will\n\t                        not be managed by the script - in particular they will not be\n\t                        automatically deleted.\n\t                        Default: /home/backuper/.rsync_tmbackup\n\t --strategy             Set the expiration strategy. Default: \"1:1 30:7 365:30\" means after one\n\t                        day, keep one backup per day. After 30 days, keep one backup every 7 days.\n\t                        After 365 days keep one backup every 30 days.\n\t --no-auto-expire       Disable automatically deleting backups when out of space. Instead an error\n\t                        is logged, and the backup is aborted.\n\n## Features\n\n* Each backup is on its own folder named after the current timestamp. Files can be copied and restored directly, without any intermediate tool.\n\n* Backup to/from remote destinations over SSH.\n\n* Files that haven't changed from one backup to the next are hard-linked to the previous backup so take very little extra space.\n\n* Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination.\n\n* Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup.\n\n* Exclude file - support for pattern-based exclusion via the `--exclude-from` rsync parameter.\n\n* Automatically purge old backups - within 24 hours, all backups are kept. Within one month, the most recent backup for each day is kept. For all previous backups, the most recent of each month is kept.\n\n* \"latest\" symlink that points to the latest successful backup.\n\n## Examples\n\t\n* Backup the home folder to backup_drive\n\t\n\t\trsync_tmbackup.sh /home /mnt/backup_drive  \n\n* Backup with exclusion list:\n\t\n\t\trsync_tmbackup.sh /home /mnt/backup_drive excluded_patterns.txt\n\n* Backup to remote drive over SSH, on port 2222:\n\n\t\trsync_tmbackup.sh -p 2222 /home user@example.com:/mnt/backup_drive\n\n\n* Backup from remote drive over SSH:\n\n\t\trsync_tmbackup.sh user@example.com:/home /mnt/backup_drive\n\n* To mimic Time Machine's behaviour, a cron script can be setup to backup at regular interval. For example, the following cron job checks if the drive \"/mnt/backup\" is currently connected and, if it is, starts the backup. It does this check every 1 hour.\n\t\t\n\t\t0 */1 * * * if grep -qs /mnt/backup /proc/mounts; then rsync_tmbackup.sh /home /mnt/backup; fi\n\n## Backup expiration logic\n\nBackup sets are automatically deleted following a simple expiration strategy defined with the `--strategy` flag. This strategy is a series of time intervals with each item being defined as `x:y`, which means \"after x days, keep one backup every y days\". The default strategy is `1:1 30:7 365:30`, which means:\n\n- After **1** day, keep one backup every **1** day (**1:1**).\n- After **30** days, keep one backup every **7** days (**30:7**).\n- After **365** days, keep one backup every **30** days (**365:30**).\n\nBefore the first interval (i.e. by default within the first 24h) it is implied that all backup sets are kept. Additionally, if the backup destination directory is full, the oldest backups are deleted until enough space is available.\n\n## Exclusion file\n\nAn optional exclude file can be provided as a third parameter. It should be compatible with the `--exclude-from` parameter of rsync. See [this tutorial](https://web.archive.org/web/20230126121643/https://sites.google.com/site/rsync2u/home/rsync-tutorial/the-exclude-from-option) for more information.\n\n## Built-in lock\n\nThe script is designed so that only one backup operation can be active for a given directory. If a new backup operation is started while another is still active (i.e. it has not finished yet), the new one will be automaticalled interrupted. Thanks to this the use of `flock` to run the script is not necessary.\n\n## Rsync options\n\nTo display the rsync options that are used for backup, run `./rsync_tmbackup.sh --rsync-get-flags`. It is also possible to add or remove options using the `--rsync-append-flags` or `--rsync-set-flags` option. For example, to exclude backing up permissions and groups:\n\n\trsync_tmbackup --rsync-append-flags \"--no-perms --no-group\" /src /dest\n\n## No automatic backup expiration\n\nAn option to disable the default behaviour to purge old backups when out of space. This option is set with the `--no-auto-expire` flag.\n\t\n\t\n## How to restore\n\nThe script creates a backup in a regular directory so you can simply copy the files back to the original directory. You could do that with something like `rsync -aP /path/to/last/backup/ /path/to/restore/to/`. Consider using the `--dry-run` option to check what exactly is going to be copied. Use `--delete` if you also want to delete files that exist in the destination but not in the backup (obviously extra care must be taken when using this option).\n\n## Extensions\n\n* [rtb-wrapper](https://github.com/thomas-mc-work/rtb-wrapper): Allows creating backup profiles in config files. Handles both backup and restore operations.\n* [time-travel](https://github.com/joekerna/time-travel): Smooth integration into OSX Notification Center\n\n## TODO\n\n* Check source and destination file-system (`df -T /dest`). If one of them is FAT, use the --modify-window rsync parameter (see `man rsync`) with a value of 1 or 2\n* Add `--whole-file` arguments on Windows? See http://superuser.com/a/905415/73619\n* Minor changes (see TODO comments in the source).\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2013-2024 Laurent Cozic\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaurent22%2Frsync-time-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaurent22%2Frsync-time-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaurent22%2Frsync-time-backup/lists"}