backup.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 10 Feb 2018 01:36:16 +0200
changeset 2229 1a0b6597e594
parent 2198 81ae8abd153a
permissions -rw-r--r--
Mark block quot in HTMLe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2177
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
=========================
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
 Backuping and restoring
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
=========================
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
rsync
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
=====
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
2180
aba1eda8608a Emulate file transfer.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2178
diff changeset
     9
Emulate file transfer with ``-n`` or by longer form ``--dry-run``.
aba1eda8608a Emulate file transfer.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2178
diff changeset
    10
2177
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
Use FS with hardlink with ``cp -l``::
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
  $ cp -al  /backup/old /backup/new
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  $ rsync -a --delete --progress /data/ /backup/new/
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
Use FS hardlink exclusively with ``rsync``::
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
  $ rsync -a --delete --progress --link-dest=../previous /data/ /backup/new/
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
.. note:: ``--link-dest`` accepts a relative path, it is relative to the
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
          destination directory.
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
.. note:: Cygwin ``rsync`` implementation can use NTFS hard links with
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
   ``--link-dest`` option. Check it with::
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
     cmd> fsutil hardlink list c:\backup\new\file.txt
d2d54cdfce7e Backuping and restoring.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
2178
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    28
Avoid carrying permissions and other attributes with::
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    29
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    30
  --no-p --no-o --no-g --no-A --no-X -O -J
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    31
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    32
To show current progress::
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    33
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    34
  -v  --progress
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    35
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    36
To copy over ssh::
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    37
2180
aba1eda8608a Emulate file transfer.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2178
diff changeset
    38
  $ rsync -n -e 'ssh -l $RUSER' -r  /archive/ $RHOST:/archive/
aba1eda8608a Emulate file transfer.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2178
diff changeset
    39
  $ rsync -n -e 'ssh -l $RUSER' -r  /archive/ $RUSER@$RHOST:/archive/
2178
abbb150314d2 Avoid carrying permissions and other attributes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2177
diff changeset
    40
2181
a657e0a7446b --size-only
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2180
diff changeset
    41
To compare only based on file size use ``--size-only``. In that case ``-t``
a657e0a7446b --size-only
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2180
diff changeset
    42
option will preserve modification time.
a657e0a7446b --size-only
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2180
diff changeset
    43
2198
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    44
To sync files only based on timestamps (if attributes have no sence, like on
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    45
Windows OS) complete invocation cn look like (final slash in path is
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    46
significant)::
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    47
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    48
  $ rsync -r -t --no-p --no-o --no-g --no-A --no-X -O -J --delete --progress -v  $FROM/ $TO/
81ae8abd153a To sync files only based on timestamps.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2181
diff changeset
    49