version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; OpenBSD amd64; rv:68.0) Gecko/20100101 Firefox/68.0 SeaMonkey/2.53.14 author=mkf charset=UTF-8 csum=add -u, improve dump-ssh funcationality. ctime=1607165727 host=198.251.81.133 name=Openbsd.Dump rev=17 targets= text=(:title Dump:)%0a%0aDump is a very useful tool for backing up entire partitions on OpenBSD. It can be done remotely.%0a%0a'''WARNING''': If your filesystem is being actively written to, data corruption may occur.%0a%0a!! Dump Primer%0a%0a[[https://man.openbsd.org/dump|dump]] is a classic BSD tool for backing up entire filesystems.%0a%0aBefore 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[@%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%0aDumping /home will require at least 28.7G of space.%0a%0aHere's a simple way to dump your /home folder:%0a%0a[@%0a$ doas dump -a -f home.dmp /home%0a@]%0a%0aThis 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%0aTo restore from the dump file to the current directory, first check the size of the dump:%0a%0a[@%0a$ du -sh home.dmp%0a29G home.dmp%0a@]%0a%0aWe 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%0aSome files do not need to be 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 group nodump 4452 Dec 29 18:53 file%0a@]%0a%0aFor 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%0adrwxr-xr-x 7 root wheel nodump 512 Oct 4 18:47 X11R6%0adrwxr-xr-x 2 root wheel nodump 5632 Nov 21 22:17 bin%0adrwxr-xr-x 2 root wheel nodump 1024 Nov 21 22:14 games%0adrwxr-xr-x 33 root bin nodump 3072 Nov 21 22:14 include%0adrwxr-xr-x 7 root wheel nodump 4608 Dec 8 19:22 lib%0a...%0a@]%0a%0aTo remove the nodump flag, run:%0a%0a[@%0a$ chflags -R dump /path/to/file%0a$ ls -lo /path/to/file%0a-rw------- 1 username group - 4452 Dec 29 18:53 file%0a@]%0a%0a!! Options%0a%0aLet's add some helpful options:%0a%0a[@%0a$ doas dump -0 -a -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@@-h 0@@ makes dump obey @@nodump@@ flags for dumps at or above level 0 (in other words, always obey nodump flags).%0a%0a@@-u@@ adds time of last backup to @@/etc/dumpdates@@, and @@security(8)@@ will notify you once it has been passed since last backup.%0a%0a!! Dump over SSH%0a%0aYou 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, and type @@reset@@ if your screen has been garbled.%0a%0a[@%0a$ doas dump -0 -a -u -h 0 -f - /home%0a@]%0a%0aWe can redirect standard output to a file:%0a%0a[@%0a$ doas dump -0 -a -u -h 0 -f - /home > home.dmp%0a@]%0a%0aWe 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%0aWe take this idea and create a script with it in the next section.%0a%0a!! Complete Functions%0a%0aPut the following functions at the end of ~/.profile:%0a%0a[@%0adump-ssh () {%0a%0a echo "Dumping in $PWD: type ctrl+c to abort, enter to continue"%0a read $cancel%0a if [ $1 ] ; then%0a remote=$1%0a else%0a remote=user@example.ircnow.org%0a fi%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /" > root.dmp%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /home/vmm" > vmm.dmp%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /mnt" > mnt.dmp%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /var" > var.dmp%0a ssh $remote "doas dump -0 -a -u -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a ssh $remote "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%0adump-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%0aSource it, then call it on the server:%0a%0a[@%0a$ . ~/.profile%0a$ dump-ssh example.ircnow.org%0a$ dump-local%0a@] time=1673369329 title=Dump author:1673369329=mkf csum:1673369329=add -u, improve dump-ssh funcationality. diff:1673369329:1639673802:=93,94d92%0a%3c @@-u@@ adds time of last backup to @@/etc/dumpdates@@, and @@security(8)@@ will notify you once it has been passed since last backup.%0a%3c %0a99,100c97,98%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, and type @@reset@@ if your screen has been garbled.%0a%3c %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> %0a102c100%0a%3c $ doas dump -0 -a -u -h 0 -f - /home%0a---%0a> $ doas dump -0 -a -h 0 -f - /home%0a108c106%0a%3c $ doas dump -0 -a -u -h 0 -f - /home > home.dmp%0a---%0a> $ doas dump -0 -a -h 0 -f - /home > home.dmp%0a114c112%0a%3c $ ssh example.ircnow.org "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a---%0a> $ ssh example.ircnow.org "doas dump -0 -a -h 0 -f - /home" > home.dmp%0a125d122%0a%3c %0a128,139c125,131%0a%3c if [ $1 ] ; then%0a%3c remote=$1%0a%3c else%0a%3c remote=user@example.ircnow.org%0a%3c fi%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /" > root.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /home/vmm" > vmm.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /mnt" > mnt.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /var" > var.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a%3c ssh $remote "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a---%0a> ssh $1 "doas dump -0 -a -h 0 -f - /" > root.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /home" > home.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /home/vmm" > vmm.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /mnt" > mnt.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /var" > var.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a> ssh $1 "doas dump -0 -a -h 0 -f - /usr" > usr.dmp%0a147,153c139,145%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---%0a> doas dump -0 -a -h 0 -f - / > root.dmp%0a> doas dump -0 -a -h 0 -f - /home > home.dmp%0a> doas dump -0 -a -h 0 -f - /home/vmm > vmm.dmp%0a> doas dump -0 -a -h 0 -f - /mnt > mnt.dmp%0a> doas dump -0 -a -h 0 -f - /var > var.dmp%0a> doas dump -0 -a -h 0 -f - /var/www/htdocs > htdocs.dmp%0a> doas dump -0 -a -h 0 -f - /usr > usr.dmp%0a host:1673369329=198.251.81.133 author:1639673802=Hawk diff:1639673802:1620899845:=52,53c52,53%0a%3c Some files do not need to be 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---%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> %0a57c57%0a%3c -rw------- 1 username group nodump 4452 Dec 29 18:53 file%0a---%0a> -rw------- 1 username username nodump 4452 Dec 29 18:53 file%0a78c78%0a%3c -rw------- 1 username group - 4452 Dec 29 18:53 file%0a---%0a> -rw------- 1 username username - 4452 Dec 29 18:53 file%0a106c106%0a%3c $ doas dump -0 -a -h 0 -f - /home > home.dmp%0a---%0a> $ doas dump -0 -a -h 0 -f - /home > usr.dmp%0a158c158%0a%3c $ . ~/.profile%0a---%0a> $ . .profile%0a host:1639673802=2001:8a0:6813:4501:cde4:df17:5501:f119 author:1620899845=jrmu diff:1620899845:1620899805:=100c100%0a%3c $ doas dump -0 -a -h 0 -f - /home%0a---%0a> $ doas dump -0 -a -u -h 0 -f - /home%0a106c106%0a%3c $ doas dump -0 -a -h 0 -f - /home > usr.dmp%0a---%0a> $ doas dump -0 -a -u -h 0 -f - /home > usr.dmp%0a112c112%0a%3c $ ssh example.ircnow.org "doas dump -0 -a -h 0 -f - /home" > home.dmp%0a---%0a> $ ssh example.ircnow.org "doas dump -0 -a -u -h 0 -f - /home" > home.dmp%0a host:1620899845=125.231.64.76 author:1620899805=jrmu diff:1620899805:1609649457:=86c86%0a%3c $ doas dump -0 -a -h 0 -f home.dmp /home%0a---%0a> $ doas dump -0 -a -u -h 0 -f home.dmp /home%0a90a91,92%0a> @@-u@@ update the file /etc/dumpdates to record a successful dump (it's needed to keep track of incremental dumps).%0a> %0a125,131c127,133%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /" > root.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /home" > home.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /home/vmm" > vmm.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /mnt" > mnt.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /var" > var.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /var/www/htdocs" > htdocs.dmp%0a%3c ssh $1 "doas dump -0 -a -h 0 -f - /usr" > usr.dmp%0a---%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%0a139,145c141,147%0a%3c doas dump -0 -a -h 0 -f - / > root.dmp%0a%3c doas dump -0 -a -h 0 -f - /home > home.dmp%0a%3c doas dump -0 -a -h 0 -f - /home/vmm > vmm.dmp%0a%3c doas dump -0 -a -h 0 -f - /mnt > mnt.dmp%0a%3c doas dump -0 -a -h 0 -f - /var > var.dmp%0a%3c doas dump -0 -a -h 0 -f - /var/www/htdocs > htdocs.dmp%0a%3c doas dump -0 -a -h 0 -f - /usr > usr.dmp%0a---%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 host:1620899805=125.231.64.76 author:1609649457=jrmu diff:1609649457:1609649261:=27d26%0a%3c [@%0a29,30c28%0a%3c @]%0a%3c %0a---%0a> %0a42d39%0a%3c [@%0a44,45c41%0a%3c @]%0a%3c %0a---%0a> %0a85d80%0a%3c [@%0a87,88c82%0a%3c @]%0a%3c %0a---%0a> %0a98a93%0a> %0a119,122c114,117%0a%3c !! Complete Functions%0a%3c %0a%3c Put the following functions at the end of ~/.profile:%0a%3c %0a---%0a> !! Complete Function%0a> %0a> Put the following function at the end of ~/.profile:%0a> %0a153,156d147%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 %0a162,163c153%0a%3c $ dump-local%0a%3c @]%0a\ No newline at end of file%0a---%0a> @]%0a host:1609649457=125.231.63.134 author:1609649261=jrmu diff:1609649261:1609648745:=81,82c81,82%0a%3c $ doas dump -0 -a -u -h 0 -f home.dmp /home%0a%3c %0a---%0a> $ doas dump -0 -a -u -h 0 -f /home.dmp%0a> %0a91,95c91,114%0a%3c You can dump to standard output instead of to a file by specifying @@-f -@@:%0a%3c %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---%0a> ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a> %0a> !! Complete Functions%0a> %0a> To backup filesystems over the internet, we can use dump and then pipe it over ssh.%0a> %0a> Put the following function at the end of ~/.profile:%0a> %0a> dump-ssh () {%0a> echo "Dumping 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> Source it, then call it on the server:%0a> %0a97c116,117%0a%3c $ doas dump -0 -a -u -h 0 -f - /home%0a---%0a> $ . .profile%0a> $ dump-ssh example.ircnow.org%0a100,119c120%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 Function%0a%3c %0a%3c Put the following function at the end of ~/.profile:%0a%3c %0a%3c [@%0a%3c dump-ssh () {%0a---%0a> dump-local () {%0a122,135d122%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%0a145,153c132%0a%3c }%0a%3c @]%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 @]%0a---%0a> }%0a\ No newline at end of file%0a host:1609649261=125.231.63.134 author:1609648745=jrmu diff:1609648745:1609648158:=7,12c7,10%0a%3c !! Dump Primer%0a%3c %0a%3c [[https://man.openbsd.org/dump|dump]] is a classic BSD tool for backing up entire filesystems.%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---%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> %0a14,20c12,14%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> $ chflags nodump /path/to/file%0a> $ ls -lo /path/to/file%0a> -rw------- 1 username username nodump 4452 Dec 29 18:53 file%0a23,32c17,18%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 $ doas dump -a -f home.dmp /home%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---%0a> For example, if you never edit or store any irreplaceable files in /usr, you can run:%0a> %0a34,35c20,27%0a%3c $ du -sh home.dmp%0a%3c 29G home.dmp%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> ...%0a38,49c30,31%0a%3c We will need at least 29G of disk space in order to restore @@home.dmp@@.%0a%3c %0a%3c $ doas restore -rf home.dmp%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---%0a> To remove the nodump flag, run:%0a> %0a51c33%0a%3c $ chflags nodump /path/to/file%0a---%0a> $ chflags -R dump /path/to/file%0a53c35%0a%3c -rw------- 1 username username nodump 4452 Dec 29 18:53 file%0a---%0a> -rw------- 1 username username - 4452 Dec 29 18:53 file%0a56,57c38,43%0a%3c For example, if you never edit or store any irreplaceable files in /usr, you can run:%0a%3c %0a---%0a> !! Dump Primer%0a> %0a> [[https://man.openbsd.org/dump|dump]] is a classic BSD tool for backing up entire filesystems.%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> %0a59,66c45,51%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---%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%0a69,70c54,63%0a%3c To remove the nodump flag, run:%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> %0a> $ doas dump -a -f home.dmp /home%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> %0a72,74c65,66%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---%0a> $ du -sh home.dmp%0a> 29G home.dmp%0a77,88c69,105%0a%3c !! Options%0a%3c %0a%3c Let's add some helpful options:%0a%3c %0a%3c $ doas dump -0 -a -u -h 0 -f /home.dmp%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---%0a> We will need at least 29G of disk space in order to restore @@home.dmp@@.%0a> %0a> $ doas restore -rf home.dmp%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> !!%0a> %0a> ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a> $ dump%0a> dump examines files on a filesystem and determines which files need to be%0a> backed up. These files are copied to the given disk, tape or other%0a> storage medium for safe keeping. A dump that is larger than the output%0a> medium is broken into multiple volumes. On most media the size is%0a> determined by writing until an end-of-media indication is returned. This%0a> can be enforced by using the -a option.%0a> %0a> %0a> %0a> $ dump -0%0a> %0a> -0-9 Dump levels. A level 0, full backup, guarantees the entire file%0a> system is copied (but see also the -h option below). A level%0a> number above 0, incremental backup, tells dump to copy all files%0a> new or modified since the last dump of a lower level. The%0a> default level is 0.%0a> %0a> will backup at level 0%0a> %0a> $ dump -f %3cfile>%0a> %0a> $ dump -f %3cfile> -h 0%0a> %0a> $ dump -f %3cfile> -h 0 %3cfiles>%0a> %0a90,93d106%0a%3c %0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a%3c %0a%3c !! Complete Functions%0a host:1609648745=125.231.63.134 author:1609648158=jrmu diff:1609648158:1609646036:=42,55d41%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 %0a58,77c44,48%0a%3c $ doas dump -a -f home.dmp /home%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 $ doas restore -rf home.dmp%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 !!%0a---%0a> $ doas dump -f home.dmp /home%0a> %0a> This will create home.dmp in your current directory. To restore it:%0a> %0a> $ doas restore %0a host:1609648158=125.231.63.134 author:1609646036=jrmu diff:1609646036:1609644554:=37,75d36%0a%3c %0a%3c !! Dump Primer%0a%3c %0a%3c [[https://man.openbsd.org/dump|dump]] is a classic BSD tool for backing up entire filesystems.%0a%3c %0a%3c Here's a simple way to dump your /home folder:%0a%3c %0a%3c $ doas dump -f home.dmp /home%0a%3c %0a%3c This will create home.dmp in your current directory. To restore it:%0a%3c %0a%3c $ doas restore %0a%3c %0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /usr" > usr.dmp%0a%3c $ dump%0a%3c dump examines files on a filesystem and determines which files need to be%0a%3c backed up. These files are copied to the given disk, tape or other%0a%3c storage medium for safe keeping. A dump that is larger than the output%0a%3c medium is broken into multiple volumes. On most media the size is%0a%3c determined by writing until an end-of-media indication is returned. This%0a%3c can be enforced by using the -a option.%0a%3c %0a%3c %0a%3c %0a%3c $ dump -0%0a%3c %0a%3c -0-9 Dump levels. A level 0, full backup, guarantees the entire file%0a%3c system is copied (but see also the -h option below). A level%0a%3c number above 0, incremental backup, tells dump to copy all files%0a%3c new or modified since the last dump of a lower level. The%0a%3c default level is 0.%0a%3c %0a%3c will backup at level 0%0a%3c %0a%3c $ dump -f %3cfile>%0a%3c %0a%3c $ dump -f %3cfile> -h 0%0a%3c %0a%3c $ dump -f %3cfile> -h 0 %3cfiles>%0a host:1609646036=125.231.63.134 author:1609644554=jrmu diff:1609644554:1609644482:=12c12%0a%3c $ chflags nodump /path/to/file%0a---%0a> $ doas chflags nodump /path/to/file%0a host:1609644554=125.231.63.134 author:1609644482=jrmu diff:1609644482:1609593215:=3c3%0a%3c Dump is a very useful tool for backing up entire partitions on OpenBSD. It can be done remotely.%0a---%0a> Dump is a very useful tool for backup entire partitions on OpenBSD. It can be done remotely.%0a host:1609644482=125.231.63.134 author:1609593215=jrmu diff:1609593215:1609592698:=49c49%0a%3c ssh $1 "doas dump -0 -a -u -h 0 -f - /home/vmm" > vmm.dmp%0a---%0a> ssh $1 "doas dump -0 -a -u -h 0 -f - /home/sftp" > sftp.dmp%0a55c55%0a%3c md5 root.dmp home.dmp vmm.dmp mnt.dmp var.dmp htdocs.dmp usr.dmp date > md5sum%0a---%0a> md5 root.dmp home.dmp sftp.dmp mnt.dmp var.dmp htdocs.dmp usr.dmp date > md5sum%0a57a58%0a> %0a63,77c64%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\ No newline at end of file%0a---%0a> @]%0a\ No newline at end of file%0a host:1609593215=125.231.63.134 author:1609592698=jrmu diff:1609592698:1609591043:=55c55%0a%3c md5 root.dmp home.dmp sftp.dmp mnt.dmp var.dmp htdocs.dmp usr.dmp date > md5sum%0a---%0a> md5 root.dmp home.dmp var.dmp usr.dmp date > md5%0a57d56%0a%3c %0a host:1609592698=125.231.63.134 author:1609591043=jrmu diff:1609591043:1609590769:=38,45c38,41%0a%3c !! Dump over SSH%0a%3c %0a%3c To backup filesystems over the internet, we can use dump and then pipe it over ssh.%0a%3c %0a%3c Put the following function at the end of ~/.profile:%0a%3c %0a%3c dump-ssh () {%0a%3c echo "Dumping in $PWD: type ctrl+c to abort, enter to continue"%0a---%0a> The following "dump over ssh" script may be useful. Put it at the end of ~/.profile:%0a> %0a> function dump-ssh {%0a> echo "dumping in $PWD: y/n"%0a host:1609591043=125.231.63.134 author:1609590769=jrmu diff:1609590769:1609590487:=34c34%0a%3c $ ls -lo /path/to/file%0a---%0a> tw$ ls -lo /path/to/file%0a host:1609590769=125.231.63.134 author:1609590487=jrmu diff:1609590487:1607165727:=1,37d0%0a%3c (:title Dump:)%0a%3c %0a%3c Dump is a very useful tool for backup entire partitions on OpenBSD. It can be done remotely.%0a%3c %0a%3c '''WARNING''': If your filesystem is being actively written to, data corruption may occur.%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 $ doas 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 tw$ ls -lo /path/to/file%0a%3c -rw------- 1 username username - 4452 Dec 29 18:53 file%0a%3c @]%0a%3c %0a host:1609590487=125.231.63.134 author:1607165727=jrmu diff:1607165727:1607165727:=1,22d0%0a%3c The following "dump over ssh" script may be useful. Put it at the end of ~/.profile:%0a%3c %0a%3c function dump-ssh {%0a%3c echo "dumping in $PWD: y/n"%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/sftp" > sftp.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 var.dmp usr.dmp date > md5%0a%3c }%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 @]%0a\ No newline at end of file%0a host:1607165727=38.81.163.7