rsync-time-backup

Time Machine style backup with rsync.
授权协议 Readme
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 甘祺
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Rsync time backup

This 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.

It 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.

On 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.

Installation

git clone https://github.com/laurent22/rsync-time-backup

Usage

Usage: rsync_tmbackup.sh [OPTION]... <[USER@HOST:]SOURCE> <[USER@HOST:]DESTINATION> [exclude-pattern-file]

Options
 -p, --port           SSH port.
 -h, --help           Display this help message.
 --rsync-get-flags    Display the default rsync flags that are used for backup.
 --rsync-set-flags    Set the rsync flags that are going to be used for backup.
 --log-dir            Set the log file directory. If this flag is set, generated files will
                      not be managed by the script - in particular they will not be
                      automatically deleted.
 --strategy           Set the expiration strategy. Default: "1:1 30:7 365:30" means after one
                      day, keep one backup per day. After 30 days, keep one backup every 7 days.
                      After 365 days keep one backup every 30 days.
 --no-auto-expire     Set option to disable automatically purging old backups when out of space.

Features

  • Each backup is on its own folder named after the current timestamp. Files can be copied and restored directly, without any intermediate tool.

  • Backup to/from remote destinations over SSH.

  • Files that haven't changed from one backup to the next are hard-linked to the previous backup so take very little extra space.

  • Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination.

  • Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup.

  • Exclude file - support for pattern-based exclusion via the --exclude-from rsync parameter.

  • 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.

  • "latest" symlink that points to the latest successful backup.

Examples

  • Backup the home folder to backup_drive

      rsync_tmbackup.sh /home /mnt/backup_drive  
    
  • Backup with exclusion list:

      rsync_tmbackup.sh /home /mnt/backup_drive excluded_patterns.txt
    
  • Backup to remote drive over SSH, on port 2222:

      rsync_tmbackup.sh -p 2222 /home user@example.com:/mnt/backup_drive
    
  • Backup from remote drive over SSH:

      rsync_tmbackup.sh user@example.com:/home /mnt/backup_drive
    
  • 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.

      0 */1 * * * if grep -qs /mnt/backup /proc/mounts; then rsync_tmbackup.sh /home /mnt/backup; fi
    

Backup expiration logic

Backup 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:

  • After 1 day, keep one backup every 1 day (1:1).
  • After 30 days, keep one backup every 7 days (30:7).
  • After 365 days, keep one backup every 30 days (365:30).

Before 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.

Exclusion file

An optional exclude file can be provided as a third parameter. It should be compatible with the --exclude-from parameter of rsync. See this tutorial for more information.

Built-in lock

The 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.

Rsync options

To 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-set-flags option. For example, to exclude backing up permissions and groups:

rsync_tmbackup --rsync-set-flags "--numeric-ids --links --hard-links \
--one-file-system --archive --no-perms --no-group --itemize-changes" /src /dest

No automatic backup expiration

An option to disable the default behaviour to purge old backups when out of space. This option is set with the --no-auto-expire flag.

How to restore

The 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).

Extensions

  • rtb-wrapper: Allows creating backup profiles in config files. Handles both backup and restore operations.
  • time-travel: Smooth integration into OSX Notification Center

TODO

  • 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
  • Add --whole-file arguments on Windows? See http://superuser.com/a/905415/73619
  • Minor changes (see TODO comments in the source).

LICENSE

The MIT License (MIT)

Copyright (c) 2013-2018 Laurent Cozic

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.

  • 一、功能 rsync是一款开源的、快速的、多功能的、可实现全量及增量的本地或远程数据同步备份的优秀工具。rsync软件适用于unix/linux/windows等, 目前,已支持跨平台,可以在Windows与Linux间进行数据同步。 特征: 可以镜像保存整个目录树和文件系统; 可以很容易做到保持源文件的权限, 时间,软硬链接等; 无需特殊权限即可安装; 优化流程,传输效率高; 可以使用scp,

  • 介绍 rsync是一个有名的Linux端同步工具,最大的特点是参数非常详细,可以实现多种多样的传输要求,该工具本身是一个Linux平台软件,在Windows端对应的是cwRsync,使用方法和原来的Rsync类似。由于cwRsync只是用Cygwin将rsync移植到Windows平台的,所以可以用于linux到Windows、Windows到Linux、Windows到Windows等等。 参数

  • 一、简介 rsync 是一个常用的 Linux 应用程序,用于文件同步。 它可以在本地计算机与远程计算机之间,或者两个本地目录之间同步文件(但不支持两台远程计算机之间的同步)。它也可以当作文件复制工具,替代cp和mv命令。 它名称里面的r指的是 remote,rsync 其实就是"远程同步"(remote sync)的意思。与其他文件传输工具(如 FTP 或 scp)不同,rsync 的最大特点是

  •   wget  https://download.samba.org/pub/rsync/src/rsync-3.2.3.tar.gz   tar -zxvf rsync-3.2.3.tar.gz   cd rsync-3.2.3   ./configure --prefix=/usr/local/rsync --disable-lz4 --disable-xxhash --without-inc

  • 参考链接 https://www.cnblogs.com/bill2014/p/7416289.html rsync+inotify:https://www.cnblogs.com/bill2014/p/7411711.html keepalive+rsync+inotify:https://www.fandenggui.com/post/keepalived-rsync-inotify.html

  • 一。简介 rsync 是一个做远程同步用的Linux命令。 (文章没有提及Windows版的cwrsync)   安装方式:1.ubuntu  apt-get  install  rsync     2. centos  yum install rsync  不再赘述。   启动:客户端和服务端都得启动。    rsync  --daemon  就启动了。 ps -ef|grep rsync  |

  • rsync --daemon端配置 [root@rsync-daemon etc]# /etc/init.d/iptables stop [root@rsync-daemon ~]# dos2unix rsyncd.conf dos2unix: converting file rsyncd.conf to UNIX format ... [root@rsync-daemon ~]# cp rsy

  • rsync 是一个能够高效远程更新的文件传输程序,使用快速差分算法。 用法         rsync [OPTION]... SRC [SRC]... DEST         rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST         rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST      

  • rsync 的命令格式 rsync [OPTION]… SRC DEST 推荐在 SSH 的基础上使用rsync。可以事先在~/.ssh/config中加入配置,这样远端可以写作SSH配置名:路径。 目录SRC是否以斜杠结尾,会影响同步的结果: 以斜杠结尾:目录DEST里面有 [目录SRC里面的文件] 不以斜杠结尾:目录DEST里面有 [目录SRC本身] 目录DEST是否以斜杠结尾,对同步的结果没

  • 1.为什么要做备份? 数据非常的重要 保证数据不丢失 便于快速的恢复 2.能不能不做备份? 可以,对于不是特别重要的数据可以不考虑   3.备份怎么做? 完全备份,全备,效率低下。 增量备份,增备,效率较高。 4.用什么工具做备份? scp 网络之间的拷贝,全量拷贝的方式 (ssh协议) rsync 远程同步(增量)       rsync是一款开源的备份工具, 可以在不同主机之间进行同步(win

  • 作为一个程序员,经常可能会面对几十台、几百台甚至上千台服务器,除了批量操作外,环境同步、数据同步也是必不可少的技能。 说到“同步”,不得不提的利器就是rsync。rsync不但可以在本机进行文件同步,也可以作为远程同步工具。 前面提到了Rsync+Inotify实时同步方案部署,rsync同步命令中常用的几个参数说明: -a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属

  • 架构-- rsync 一 、主机名字与网卡修改脚本 [root@nfs ~]# cat zhuji.sh #!/bin/bash hostnamectl set-hostname $1 sed -i "s#41#$2#g" /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i "s#41#$2#g" /etc/sysconfig/network-scr

 相关资料
  • rsync(Remote Sync)。你有两个目录想保持同步,可以使用 rsync 。要同步的目录可以是本地之间的目录,也可以是本地与远程之间的目录。 rsync 选项 源 目标 选项 r(recursive),递归复制,复制同步的文件不保留文件的权限,创建与修改时间。 a(archive),存档模式,可以递归复制,保留文件替身,复制同步的文件会保留文件的拥有者,用户名,时间,权限。 z(com

  • rsync是类unix系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync。它的特性如下: 1、可以镜像保存整个目录树和文件系统。 2、可以很容易做到保持原来文件的权限、时间、软硬链接等等。 3、无须特殊权限即可安装。 4、优化的流程,文件传输效率高。 5、可以使用rcp、ssh等方式来传输文件,当然也可以通过直接的socket连接。 6、支持匿名传输。 Linux系统下如何使用rsync进行数据同步

  • GAdmin-Rsync 是图形化的 Rsync 的管理工具。

  • mrsync 通过多播技术将文件从一台主机同时同步到局域网中的多台机器。其拥有的堵塞处理机制可以轻松处理因网络问题导致的同步中断。 在一个典型的千兆网络环境中,mrsync可以在4个小时内将140G大小的文件传输到100个节点。

  • function getCarData() { return [ ["Mercedes", "A 160", 1332284400000, 6999.95], ["Citroen", "C4 Coupe", '10 30', 8330], ["Audi", "A4 Avant", "8:00 PM", 33900], ["Opel", "Astra", 1332284400000, 7

  • .time( value:Number ) : * 获取或设置当前动画时间。 var currentTime = myTween.time(); //gets current time myTween.time(2); //sets time, jumping to new value just like seek(). .time()适用于TweenMaxTweenLite .time()的参数