backup.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 16 Sep 2019 22:13:19 +0300
changeset 2376 20b65f046002
parent 2198 81ae8abd153a
permissions -rw-r--r--
Revoke privileges and drop role.


=========================
 Backuping and restoring
=========================

rsync
=====

Emulate file transfer with ``-n`` or by longer form ``--dry-run``.

Use FS with hardlink with ``cp -l``::

  $ cp -al  /backup/old /backup/new
  $ rsync -a --delete --progress /data/ /backup/new/

Use FS hardlink exclusively with ``rsync``::

  $ rsync -a --delete --progress --link-dest=../previous /data/ /backup/new/

.. note:: ``--link-dest`` accepts a relative path, it is relative to the
          destination directory.

.. note:: Cygwin ``rsync`` implementation can use NTFS hard links with
   ``--link-dest`` option. Check it with::

     cmd> fsutil hardlink list c:\backup\new\file.txt

Avoid carrying permissions and other attributes with::

  --no-p --no-o --no-g --no-A --no-X -O -J

To show current progress::

  -v  --progress

To copy over ssh::

  $ rsync -n -e 'ssh -l $RUSER' -r  /archive/ $RHOST:/archive/
  $ rsync -n -e 'ssh -l $RUSER' -r  /archive/ $RUSER@$RHOST:/archive/

To compare only based on file size use ``--size-only``. In that case ``-t``
option will preserve modification time.

To sync files only based on timestamps (if attributes have no sence, like on
Windows OS) complete invocation cn look like (final slash in path is
significant)::

  $ rsync -r -t --no-p --no-o --no-g --no-A --no-X -O -J --delete --progress -v  $FROM/ $TO/