version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=w3m/0.5.3+git20210102 author=jrmu charset=UTF-8 csum= ctime=1610436474 host=38.87.162.8 name=Openbsd.Openrsync rev=7 targets= text=(:redirect rsync/usage:)%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%0a'''WARNING''': If your filesystem is being actively written to, data corruption may occur.%0a%0a!! Rsync Primer%0a%0aOpenBSD 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%0aHere's how to back up the file /path/to/file on ircnow.org with username to the current directory:%0a%0a[@%0a$ rsync -a username@ircnow.org:/path/to/file ./%0a@]%0a%0aWe add the option @@-a@@ for archive mode.%0a%0aIf you have multiple files, you can use the shorthand of :/path/to/second/file:%0a%0a[@%0a$ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a@]%0a%0aThis copies both /path/to/file and /path/to/second/file from ircnow.org to your current local directory.%0a%0a[@%0a$ rsync -a username@ircnow.org:/path/to/file :/path/to/second/file ./%0a@]%0a%0aWe add @@-v@@ options to turn on verbosity (it will display each file copied).%0a%0a[@%0a$ rsync username@ircnow.org:/path/to/file ./%0a@]%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[@%0a$ rsync --rsync-path="doas rsync" -av jrmu@jrmu.coconut.ircnow.org:/home /dest/path/%0a@]%0a%0aThis will copy everything in /home into /dest/path/. @@-a@@ specifies this is an archive, @@-v@@ tells rsync to be more verbose (show files).%0a%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.ircnow.org%0a@]%0a time=1626616918 title=Rsync author:1626616918=jrmu diff:1626616918:1610438988:=1d0%0a%3c (:redirect rsync/usage:)%0a88c87%0a%3c @]%0a---%0a> @]%0a\ No newline at end of file%0a host:1626616918=38.87.162.8 author:1610438988=jrmu diff:1610438988:1610438235:=12,31d11%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 host:1610438988=125.224.27.48 author:1610438235=jrmu diff:1610438235:1610438110:=7,12c7,10%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---%0a> !! Quick Check%0a> %0a> 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> %0a14c12,18%0a%3c $ rsync username@ircnow.org:/path/to/file ./%0a---%0a> $ df -h%0a> Filesystem 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%0a17,21c21,28%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---%0a> Backing up /home will require at least 28.7G of space.%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 ircnow.org with username to the current directory:%0a> %0a23,29c30%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---%0a> $ rsync username@ircnow.org:/path/to/file ./%0a32c33%0a%3c Backing up /home will require at least 28.7G of space.%0a---%0a> %0a host:1610438235=125.224.27.48 author:1610438110=jrmu diff:1610438110:1610437835:=23,24c23,24%0a%3c !! Rsync Primer%0a%3c %0a---%0a> !! Dump Primer%0a> %0a26,34d25%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 username@ircnow.org:/path/to/file ./%0a%3c @]%0a%3c %0a%3c %0a%3c %0a host:1610438110=125.224.27.48 author:1610437835=jrmu diff:1610437835:1610437026:=38,39c38,39%0a%3c rsync-all () {%0a%3c echo "Backing up in $PWD: type ctrl+c to abort, enter to continue"%0a---%0a> dump-ssh () {%0a> echo "Dumping in $PWD: type ctrl+c to abort, enter to continue"%0a52,53c52,70%0a%3c @@rsync-all@@ will make a complete backup of the remote system you specify.%0a%3c %0a---%0a> dump-local () {%0a> echo "Dumping in $PWD: type ctrl+c to abort, enter to continue"%0a> read $cancel%0a> doas dump -0 -a -u -h 0 -f - / > root.dmp%0a> doas dump -0 -a -u -h 0 -f - /home > home.dmp%0a> doas dump -0 -a -u -h 0 -f - /home/vmm > vmm.dmp%0a> doas dump -0 -a -u -h 0 -f - /mnt > mnt.dmp%0a> doas dump -0 -a -u -h 0 -f - /var > var.dmp%0a> doas dump -0 -a -u -h 0 -f - /var/www/htdocs > htdocs.dmp%0a> 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> %0a> @@dump-local@@ will make a complete local backup of the current system, and @@dump-ssh@@ will make a complete remote backup of the server you specify.%0a> %0a> '''WARNING''': If you have any other partitions besides the ones in the function, you must add them, or the partition will '''not''' get backed up.%0a> %0a58c75,76%0a%3c $ rsync-all example.ircnow.org%0a---%0a> $ dump-ssh example.ircnow.org%0a> $ dump-local%0a host:1610437835=125.224.27.48 author:1610437026=jrmu diff:1610437026:1610436474:=3,4c3,4%0a%3c [[https://rsync.samba.org/|Rsync]] is a very useful tool for backing up files. It can be used remotely.%0a%3c %0a---%0a> Rsync is a very useful tool for backing up files on OpenBSD. It can be used remotely.%0a> %0a7,10c7,10%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---%0a> !! Dump Primer%0a> %0a> OpenBSD includes its own rewrite of rsync called [[https://man.openbsd.org/openrsync|openrsync]].%0a> %0a11a12,17%0a> $ openrsync --rsync-path=openrsync -av jrmu@jrmu.coconut.ircnow.org:/home/jrmu ./%0a> @]%0a> %0a> Before you dump, make sure you have enough disk space for the entire dump. To see how much space it will take, and how much you have available, run:%0a> %0a> [@%0a21,26c27,30%0a%3c Backing up /home will require at least 28.7G of space.%0a%3c %0a%3c !! Dump 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---%0a> Dumping /home will require at least 28.7G of space.%0a> %0a> Here's a simple way to dump your /home folder:%0a> %0a28c32%0a%3c $ rsync --rsync-path="doas rsync" -av jrmu@jrmu.coconut.ircnow.org:/home /dest/path/%0a---%0a> $ doas dump -a -f home.dmp /home%0a31,36c35,121%0a%3c This will copy everything in /home into /dest/path/. @@-a@@ specifies this is an archive, @@-v@@ tells rsync to be more verbose (show files).%0a%3c %0a%3c !! Complete Functions%0a%3c %0a%3c Put the following functions at the end of ~/.profile:%0a%3c %0a---%0a> This will create home.dmp in your current directory. @@-f@@ tells you where the dump file will be created, @@/home@@ is the partition, and @@-a@@ tells dump to "auto-size".%0a> %0a> To restore from the dump file to the current directory, first check the size of the dump:%0a> %0a> [@%0a> $ du -sh home.dmp%0a> 29G home.dmp%0a> @]%0a> %0a> We will need at least 29G of disk space in order to restore @@home.dmp@@.%0a> %0a> [@%0a> $ doas restore -rf home.dmp%0a> @]%0a> %0a> @@-r@@ restores the file system and @@-f@@ reads it from the file home.dmp.%0a> %0a> '''NOTE''': It is recommended that you restore on a newly created filesystem, see [[https://man.openbsd.org/restore|the man page]] for details.%0a> %0a> !! nodump flags%0a> %0a> Some files do not need to backed up because they can easily be downloaded elsewhere. These files can be set to @@nodump@@ using @@chflags@@. You can then use @@ls -lo@@ to view the special flag:%0a> %0a> [@%0a> $ chflags nodump /path/to/file%0a> $ ls -lo /path/to/file%0a> -rw------- 1 username username nodump 4452 Dec 29 18:53 file%0a> @]%0a> %0a> For example, if you never edit or store any irreplaceable files in /usr, you can run:%0a> %0a> [@%0a> $ doas chflags -R nodump /usr%0a> $ ls -lo /usr%0a> drwxr-xr-x 7 root wheel nodump 512 Oct 4 18:47 X11R6%0a> drwxr-xr-x 2 root wheel nodump 5632 Nov 21 22:17 bin%0a> drwxr-xr-x 2 root wheel nodump 1024 Nov 21 22:14 games%0a> drwxr-xr-x 33 root bin nodump 3072 Nov 21 22:14 include%0a> drwxr-xr-x 7 root wheel nodump 4608 Dec 8 19:22 lib%0a> ...%0a> @]%0a> %0a> To remove the nodump flag, run:%0a> %0a> [@%0a> $ chflags -R dump /path/to/file%0a> $ ls -lo /path/to/file%0a> -rw------- 1 username username - 4452 Dec 29 18:53 file%0a> @]%0a> %0a> !! Options%0a> %0a> Let's add some helpful options:%0a> %0a> [@%0a> $ doas dump -0 -a -u -h 0 -f home.dmp /home%0a> @]%0a> %0a> @@-0@@ requests a full backup (a complete copy of the file system). You can use @@-1@@, @@-2@@ and so forth to perform an incremental backup: only files that are new or modified since the last dump of a lower level are copied.%0a> %0a> @@-u@@ update the file /etc/dumpdates to record a successful dump (it's needed to keep track of incremental dumps).%0a> %0a> @@-h 0@@ makes dump obey @@nodump@@ flags for dumps at or above level 0 (in other words, always obey nodump flags).%0a> %0a> !! Dump over SSH%0a> %0a> You can dump to standard output instead of to a file by specifying @@-f -@@:%0a> %0a> '''WARNING''': Do not actually run the next line of code, or else your screen will be garbled and your system may crash. Type @@ctrl+c@@ to cancel if you already have.%0a> %0a> [@%0a> $ doas dump -0 -a -u -h 0 -f - /home%0a> @]%0a> %0a> We can redirect standard output to a file:%0a> %0a> [@%0a> $ doas dump -0 -a -u -h 0 -f - /home > usr.dmp%0a> @]%0a> %0a> We can use a remote host to run the dump command using ssh, then redirect the standard output to a file:%0a> %0a> [@%0a> $ ssh example.ircnow.org "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a> @]%0a> %0a> We take this idea and create a script with it in the next section.%0a host:1610437026=125.224.27.48 author:1610436474=jrmu diff:1610436474:1610436474:=1,167d0%0a%3c (:title Rsync:)%0a%3c %0a%3c Rsync is a very useful tool for backing up files on OpenBSD. 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 !! Dump Primer%0a%3c %0a%3c OpenBSD includes its own rewrite of rsync called [[https://man.openbsd.org/openrsync|openrsync]].%0a%3c %0a%3c [@%0a%3c $ openrsync --rsync-path=openrsync -av jrmu@jrmu.coconut.ircnow.org:/home/jrmu ./%0a%3c @]%0a%3c %0a%3c Before you dump, make sure you have enough disk space for the entire dump. 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 Dumping /home will require at least 28.7G of space.%0a%3c %0a%3c Here's a simple way to dump your /home folder:%0a%3c %0a%3c [@%0a%3c $ doas dump -a -f home.dmp /home%0a%3c @]%0a%3c %0a%3c This will create home.dmp in your current directory. @@-f@@ tells you where the dump file will be created, @@/home@@ is the partition, and @@-a@@ tells dump to "auto-size".%0a%3c %0a%3c To restore from the dump file to the current directory, first check the size of the dump:%0a%3c %0a%3c [@%0a%3c $ du -sh home.dmp%0a%3c 29G home.dmp%0a%3c @]%0a%3c %0a%3c We will need at least 29G of disk space in order to restore @@home.dmp@@.%0a%3c %0a%3c [@%0a%3c $ doas restore -rf home.dmp%0a%3c @]%0a%3c %0a%3c @@-r@@ restores the file system and @@-f@@ reads it from the file home.dmp.%0a%3c %0a%3c '''NOTE''': It is recommended that you restore on a newly created filesystem, see [[https://man.openbsd.org/restore|the man page]] for details.%0a%3c %0a%3c !! nodump flags%0a%3c %0a%3c Some files do not need to backed up because they can easily be downloaded elsewhere. These files can be set to @@nodump@@ using @@chflags@@. You can then use @@ls -lo@@ to view the special flag:%0a%3c %0a%3c [@%0a%3c $ chflags nodump /path/to/file%0a%3c $ ls -lo /path/to/file%0a%3c -rw------- 1 username username nodump 4452 Dec 29 18:53 file%0a%3c @]%0a%3c %0a%3c For example, if you never edit or store any irreplaceable files in /usr, you can run:%0a%3c %0a%3c [@%0a%3c $ doas chflags -R nodump /usr%0a%3c $ ls -lo /usr%0a%3c drwxr-xr-x 7 root wheel nodump 512 Oct 4 18:47 X11R6%0a%3c drwxr-xr-x 2 root wheel nodump 5632 Nov 21 22:17 bin%0a%3c drwxr-xr-x 2 root wheel nodump 1024 Nov 21 22:14 games%0a%3c drwxr-xr-x 33 root bin nodump 3072 Nov 21 22:14 include%0a%3c drwxr-xr-x 7 root wheel nodump 4608 Dec 8 19:22 lib%0a%3c ...%0a%3c @]%0a%3c %0a%3c To remove the nodump flag, run:%0a%3c %0a%3c [@%0a%3c $ chflags -R dump /path/to/file%0a%3c $ ls -lo /path/to/file%0a%3c -rw------- 1 username username - 4452 Dec 29 18:53 file%0a%3c @]%0a%3c %0a%3c !! Options%0a%3c %0a%3c Let's add some helpful options:%0a%3c %0a%3c [@%0a%3c $ doas dump -0 -a -u -h 0 -f home.dmp /home%0a%3c @]%0a%3c %0a%3c @@-0@@ requests a full backup (a complete copy of the file system). You can use @@-1@@, @@-2@@ and so forth to perform an incremental backup: only files that are new or modified since the last dump of a lower level are copied.%0a%3c %0a%3c @@-u@@ update the file /etc/dumpdates to record a successful dump (it's needed to keep track of incremental dumps).%0a%3c %0a%3c @@-h 0@@ makes dump obey @@nodump@@ flags for dumps at or above level 0 (in other words, always obey nodump flags).%0a%3c %0a%3c !! Dump over SSH%0a%3c %0a%3c You can dump to standard output instead of to a file by specifying @@-f -@@:%0a%3c %0a%3c '''WARNING''': Do not actually run the next line of code, or else your screen will be garbled and your system may crash. Type @@ctrl+c@@ to cancel if you already have.%0a%3c %0a%3c [@%0a%3c $ doas dump -0 -a -u -h 0 -f - /home%0a%3c @]%0a%3c %0a%3c We can redirect standard output to a file:%0a%3c %0a%3c [@%0a%3c $ doas dump -0 -a -u -h 0 -f - /home > usr.dmp%0a%3c @]%0a%3c %0a%3c We can use a remote host to run the dump command using ssh, then redirect the standard output to a file:%0a%3c %0a%3c [@%0a%3c $ ssh example.ircnow.org "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a%3c @]%0a%3c %0a%3c We take this idea and create a script with it in the next section.%0a%3c %0a%3c !! Complete Functions%0a%3c %0a%3c Put the following functions at the end of ~/.profile:%0a%3c %0a%3c [@%0a%3c dump-ssh () {%0a%3c echo "Dumping 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 dump-local () {%0a%3c echo "Dumping in $PWD: type ctrl+c to abort, enter to continue"%0a%3c read $cancel%0a%3c doas dump -0 -a -u -h 0 -f - / > root.dmp%0a%3c doas dump -0 -a -u -h 0 -f - /home > home.dmp%0a%3c doas dump -0 -a -u -h 0 -f - /home/vmm > vmm.dmp%0a%3c doas dump -0 -a -u -h 0 -f - /mnt > mnt.dmp%0a%3c doas dump -0 -a -u -h 0 -f - /var > var.dmp%0a%3c doas dump -0 -a -u -h 0 -f - /var/www/htdocs > htdocs.dmp%0a%3c 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 %0a%3c @@dump-local@@ will make a complete local backup of the current system, and @@dump-ssh@@ will make a complete remote backup of the server you specify.%0a%3c %0a%3c '''WARNING''': If you have any other partitions besides the ones in the function, you must add them, or the partition will '''not''' get backed up.%0a%3c %0a%3c Source it, then call it on the server:%0a%3c %0a%3c [@%0a%3c $ . .profile%0a%3c $ dump-ssh example.ircnow.org%0a%3c $ dump-local%0a%3c @]%0a\ No newline at end of file%0a host:1610436474=125.224.27.48