Openrsync.Usage 14 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. version=pmwiki-2.2.130 ordered=1 urlencoded=1
  2. agent=w3m/0.5.3+git20210102
  3. author=jrmu
  4. charset=UTF-8
  5. csum=
  6. ctime=1638367297
  7. host=38.87.162.8
  8. name=Openrsync.Usage
  9. rev=12
  10. targets=
  11. text=(:title Using Openrsync:)%0a%0a[[https://www.openrsync.org/|OpenRsync]] is OpenBSD's rewrite of rsync. [[https://man.openbsd.org/openrsync|openrsync]] is designed to be lightweight and simple. It may, however, be a little buggy.%0a%0a'''WARNING''': If your filesystem is being actively written to, data corruption may occur.%0a%0a!! OpenRsync Primer%0a%0aTo back up the file /path/to/file on example.com with username to the current directory:%0a%0a[@%0a$ openrsync -a username@example.com:/path/to/file ./%0a@]%0a%0aThis table explains the most common options:%0a%0a|| border=1 width=100%25 class="sortable simpletable"%0a||! Option ||! Purpose ||%0a|| a || (a)rchive mode, shorthand for Dgloprt ||%0a|| D || Transfers (D)evice and special files ||%0a|| g || Sets (g)roup to match the source ||%0a|| l || Transfers symbolic (l)inks ||%0a|| o || Sets (o)wner to match the source (needs root) ||%0a|| p || Synchronizes (p)ermissions ||%0a|| r || (r)ecursive ||%0a|| t || Synchronize (t)imestamps ||%0a|| v || Increase (v)erbosity ||%0a%0aIf you have multiple files, you can use the shorthand of :/path/to/second/file:%0a%0a[@%0a$ openrsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a@]%0a%0aThis copies both /path/to/file and /path/to/second/file from example.com to your current local directory.%0a%0aopenrsync can also copy folders recursively. To see each file copied, turn on verbosity with @@-v@@. In the next example, we copy from /path/to/folder on the local system to /path/to/destination in @@example.com@@:%0a%0a[@%0a$ rsync -av /path/to/folder username@example.com:/path/to/destination/%0a@]%0a%0a!! Quick Check%0a%0aBefore you backup your files, make sure you have enough disk space. To see how much space it will take, and how much you have available, run:%0a%0a[@%0a$ df -h%0aFilesystem Size Used Avail Capacity Mounted on%0a/dev/sd0a 1005M 111M 844M 12%25 /%0a/dev/sd0k 192G 28.7G 153G 16%25 /home%0a/dev/sd0d 3.9G 22.1M 3.7G 1%25 /tmp%0a/dev/sd0f 12.3G 7.3G 4.4G 63%25 /usr%0a/dev/sd0e 14.7G 41.2M 14.0G 0%25 /var%0a@]%0a%0aBacking up /home will require at least 28.7G of space.%0a%0a[@%0a$ openrsync -av username@example.com:/home/username /dest/path/%0a@]%0a%0aThis will copy everything in /home/username on @@example.com@@ into /dest/path/.%0a%0a(:if false:)%0a!! Complete Functions%0a%0aPut the following functions at the end of ~/.profile:%0a%0a[@%0arsync-all () {%0a echo "Backing up in $PWD: type ctrl+c to abort, enter to continue"%0a read $cancel%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /" > root.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /home/vmm" > vmm.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /mnt" > mnt.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /var" > var.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a date > date%0a md5 root.dmp home.dmp vmm.dmp mnt.dmp var.dmp htdocs.dmp usr.dmp date > md5sum%0a}%0a%0a@@rsync-all@@ will make a complete backup of the remote system you specify.%0a%0aSource it, then call it on the server:%0a%0a[@%0a$ . .profile%0a$ rsync-all example.com%0a@]%0a(:ifend:)%0a
  12. time=1638445945
  13. title=Using Openrsync
  14. author:1638445945=jrmu
  15. diff:1638445945:1638445881:=60c60%0a%3c $ openrsync -av username@example.com:/home/username /dest/path/%0a---%0a> $ openrsync --rsync-path="doas rsync" -avz username@example.com:/home/username /dest/path/%0a63c63%0a%3c This will copy everything in /home/username on @@example.com@@ into /dest/path/.%0a---%0a> This will copy everything in /home/username on example.com into /dest/path/. @@-a@@ specifies this is an archive, @@-v@@ tells rsync to be more verbose (show files), and @@z@@ tells rsync to compress during the transfer..%0a
  16. host:1638445945=38.87.162.8
  17. author:1638445881=jrmu
  18. diff:1638445881:1638445753:=58a59%0a> %0a60c61%0a%3c $ openrsync --rsync-path="doas rsync" -avz username@example.com:/home/username /dest/path/%0a---%0a> $ rsync --rsync-path="doas rsync" -avz username@example.com:/home/username /dest/path/%0a
  19. host:1638445881=38.87.162.8
  20. author:1638445753=jrmu
  21. diff:1638445753:1638445126:=9,10c9,10%0a%3c To back up the file /path/to/file on example.com with username to the current directory:%0a%3c %0a---%0a> To back up the folder /path/to/folder on example.com with username to the current directory:%0a> %0a12c12%0a%3c $ openrsync -a username@example.com:/path/to/file ./%0a---%0a> $ openrsync -aDgloprtv username@example.com:/path/to/folder ./%0a15,16c15,16%0a%3c This table explains the most common options:%0a%3c %0a---%0a> This table explains what the options mean:%0a> %0a19c19%0a%3c || a || (a)rchive mode, shorthand for Dgloprt ||%0a---%0a> || a || (a)rchive mode ||%0a32c32%0a%3c $ openrsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a---%0a> $ rsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a37,38d36%0a%3c openrsync can also copy folders recursively. To see each file copied, turn on verbosity with @@-v@@. In the next example, we copy from /path/to/folder on the local system to /path/to/destination in @@example.com@@:%0a%3c %0a40c38%0a%3c $ rsync -av /path/to/folder username@example.com:/path/to/destination/%0a---%0a> $ rsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a41a40,46%0a> %0a> We add @@-v@@ options to turn on verbosity (it will display each file copied).%0a> %0a> [@%0a> $ rsync -v username@example.com:/path/to/file ./%0a> @]%0a> %0a
  22. host:1638445753=38.87.162.8
  23. author:1638445126=jrmu
  24. diff:1638445126:1638444835:=9,10c9,10%0a%3c To back up the folder /path/to/folder on example.com with username to the current directory:%0a%3c %0a---%0a> To back up the file /path/to/file on example.com with username to the current directory:%0a> %0a12c12%0a%3c $ openrsync -aDgloprtv username@example.com:/path/to/folder ./%0a---%0a> $ rsync -aDgloprt username@example.com:/path/to/file ./%0a15,16d14%0a%3c This table explains what the options mean:%0a%3c %0a26,27c24,26%0a%3c || t || Synchronize (t)imestamps ||%0a%3c || v || Increase (v)erbosity ||%0a---%0a> || t || ||%0a> || v || ||%0a> %0a
  25. host:1638445126=38.87.162.8
  26. author:1638444835=jrmu
  27. diff:1638444835:1638444588:=15,26c15%0a%3c || border=1 width=100%25 class="sortable simpletable"%0a%3c ||! Option ||! Purpose ||%0a%3c || a || (a)rchive mode ||%0a%3c || D || Transfers (D)evice and special files ||%0a%3c || g || Sets (g)roup to match the source ||%0a%3c || l || Transfers symbolic (l)inks ||%0a%3c || o || Sets (o)wner to match the source (needs root) ||%0a%3c || p || Synchronizes (p)ermissions ||%0a%3c || r || (r)ecursive ||%0a%3c || t || ||%0a%3c || v || ||%0a%3c %0a---%0a> @@-a@@ is for archive mode, @@-D@@ transfers device and special files, @@-g@@ sets the group to match the source, @@-l@@ transfers links, @@-o@@ sets the owner to match the source (requires running as root), @@-p@@ synchronizes permissions, @@-r@@ recursive:%0a
  28. host:1638444835=38.87.162.8
  29. author:1638444588=jrmu
  30. diff:1638444588:1638444473:=15c15%0a%3c @@-a@@ is for archive mode, @@-D@@ transfers device and special files, @@-g@@ sets the group to match the source, @@-l@@ transfers links, @@-o@@ sets the owner to match the source (requires running as root), @@-p@@ synchronizes permissions, @@-r@@ recursive:%0a---%0a> We add the option @@-a@@ for archive mode.%0a
  31. host:1638444588=38.87.162.8
  32. author:1638444473=jrmu
  33. diff:1638444473:1638444396:=
  34. host:1638444473=38.87.162.8
  35. author:1638444396=jrmu
  36. diff:1638444396:1638431383:=12c12%0a%3c $ rsync -aDgloprt username@example.com:/path/to/file ./%0a---%0a> $ rsync -a username@example.com:/path/to/file ./%0a
  37. host:1638444396=38.87.162.8
  38. author:1638431383=jrmu
  39. diff:1638431383:1638369375:=1,4c1,4%0a%3c (:title Using Openrsync:)%0a%3c %0a%3c [[https://www.openrsync.org/|OpenRsync]] is OpenBSD's rewrite of rsync. [[https://man.openbsd.org/openrsync|openrsync]] is designed to be lightweight and simple. It may, however, be a little buggy.%0a%3c %0a---%0a> (:title Openrsync:)%0a> %0a> [[https://www.openrsync.org/|OpenRsync]] is a very useful tool for backing up files. It can be used remotely.%0a> %0a7,9c7,11%0a%3c !! OpenRsync Primer%0a%3c %0a%3c To back up the file /path/to/file on example.com with username to the current directory:%0a---%0a> !! Rsync Primer%0a> %0a> OpenBSD includes its own rewrite of rsync called [[https://man.openbsd.org/openrsync|openrsync]]. It seems to be a bit buggy so I am going to use rsync instead. The commands below, however, will work with either openrsync or rsync.%0a> %0a> Here's how to back up the file /path/to/file on example.com with username to the current directory:%0a
  40. host:1638431383=38.87.162.8
  41. author:1638369375=jrmu
  42. diff:1638369375:1638367480:=11,12c11,12%0a%3c Here's how to back up the file /path/to/file on example.com with username to the current directory:%0a%3c %0a---%0a> Here's how to back up the file /path/to/file on ircnow.org with username to the current directory:%0a> %0a14c14%0a%3c $ rsync -a username@example.com:/path/to/file ./%0a---%0a> $ rsync -a username@ircnow.org:/path/to/file ./%0a22c22%0a%3c $ rsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a---%0a> $ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a25,26c25,26%0a%3c This copies both /path/to/file and /path/to/second/file from example.com to your current local directory.%0a%3c %0a---%0a> This copies both /path/to/file and /path/to/second/file from ircnow.org to your current local directory.%0a> %0a28c28%0a%3c $ rsync -a username@example.com:/path/to/file :/path/to/second/file ./%0a---%0a> $ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a34c34%0a%3c $ rsync -v username@example.com:/path/to/file ./%0a---%0a> $ rsync -v username@ircnow.org:/path/to/file ./%0a87c87%0a%3c $ rsync-all example.com%0a---%0a> $ rsync-all example.ircnow.org%0a
  43. host:1638369375=38.87.162.8
  44. author:1638367480=jrmu
  45. diff:1638367480:1638367297:=1,3c1,3%0a%3c (:title Openrsync:)%0a%3c %0a%3c [[https://www.openrsync.org/|OpenRsync]] is a very useful tool for backing up files. It can be used remotely.%0a---%0a> (:title Rsync:)%0a> %0a> [[https://rsync.samba.org/|Rsync]] is a very useful tool for backing up files. It can be used remotely.%0a
  46. host:1638367480=38.87.162.8
  47. author:1638367297=jrmu
  48. diff:1638367297:1638367297:=1,89d0%0a%3c (:title Rsync:)%0a%3c %0a%3c [[https://rsync.samba.org/|Rsync]] is a very useful tool for backing up files. It can be used remotely.%0a%3c %0a%3c '''WARNING''': If your filesystem is being actively written to, data corruption may occur.%0a%3c %0a%3c !! Rsync Primer%0a%3c %0a%3c OpenBSD includes its own rewrite of rsync called [[https://man.openbsd.org/openrsync|openrsync]]. It seems to be a bit buggy so I am going to use rsync instead. The commands below, however, will work with either openrsync or rsync.%0a%3c %0a%3c Here's how to back up the file /path/to/file on ircnow.org with username to the current directory:%0a%3c %0a%3c [@%0a%3c $ rsync -a username@ircnow.org:/path/to/file ./%0a%3c @]%0a%3c %0a%3c We add the option @@-a@@ for archive mode.%0a%3c %0a%3c If you have multiple files, you can use the shorthand of :/path/to/second/file:%0a%3c %0a%3c [@%0a%3c $ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a%3c @]%0a%3c %0a%3c This copies both /path/to/file and /path/to/second/file from ircnow.org to your current local directory.%0a%3c %0a%3c [@%0a%3c $ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a%3c @]%0a%3c %0a%3c We add @@-v@@ options to turn on verbosity (it will display each file copied).%0a%3c %0a%3c [@%0a%3c $ rsync -v username@ircnow.org:/path/to/file ./%0a%3c @]%0a%3c %0a%3c %0a%3c !! Quick Check%0a%3c %0a%3c Before you backup your files, make sure you have enough disk space. To see how much space it will take, and how much you have available, run:%0a%3c %0a%3c [@%0a%3c $ df -h%0a%3c Filesystem Size Used Avail Capacity Mounted on%0a%3c /dev/sd0a 1005M 111M 844M 12%25 /%0a%3c /dev/sd0k 192G 28.7G 153G 16%25 /home%0a%3c /dev/sd0d 3.9G 22.1M 3.7G 1%25 /tmp%0a%3c /dev/sd0f 12.3G 7.3G 4.4G 63%25 /usr%0a%3c /dev/sd0e 14.7G 41.2M 14.0G 0%25 /var%0a%3c @]%0a%3c %0a%3c Backing up /home will require at least 28.7G of space.%0a%3c %0a%3c %0a%3c [@%0a%3c $ rsync --rsync-path="doas rsync" -avz username@example.com:/home/username /dest/path/%0a%3c @]%0a%3c %0a%3c This will copy everything in /home/username on example.com into /dest/path/. @@-a@@ specifies this is an archive, @@-v@@ tells rsync to be more verbose (show files), and @@z@@ tells rsync to compress during the transfer..%0a%3c %0a%3c (:if false:)%0a%3c !! Complete Functions%0a%3c %0a%3c Put the following functions at the end of ~/.profile:%0a%3c %0a%3c [@%0a%3c rsync-all () {%0a%3c echo "Backing up in $PWD: type ctrl+c to abort, enter to continue"%0a%3c read $cancel%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /" > root.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /home/vmm" > vmm.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /mnt" > mnt.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /var" > var.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a%3c date > date%0a%3c md5 root.dmp home.dmp vmm.dmp mnt.dmp var.dmp htdocs.dmp usr.dmp date > md5sum%0a%3c }%0a%3c %0a%3c @@rsync-all@@ will make a complete backup of the remote system you specify.%0a%3c %0a%3c Source it, then call it on the server:%0a%3c %0a%3c [@%0a%3c $ . .profile%0a%3c $ rsync-all example.ircnow.org%0a%3c @]%0a%3c (:ifend:)%0a
  49. host:1638367297=38.87.162.8