imported>Jacob |
imported>Jacob |
| (6 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| <hr><p style="text align:left;"> | | <hr> |
| Previous [[Poudriere setup]] | | <p style="text align:left;"> Previous [[Poudriere setup]] |
| <span style="float:right;"> | | <span style="float:right;"> Next [[Firewall Switch]]</span></p> |
| Return [[Freebsd Knowledge Base]]
| | <hr> |
| </span></p><hr> | |
|
| |
|
| ==== ZFS Backup Synopsis ==== | | ==== ZFS Backup Synopsis ==== |
| Line 20: |
Line 19: |
| === To file. === | | === To file. === |
| ZFS backups to file will be stored in a directory per server. On the dataset "zbackup/var/zfsbackup". | | ZFS backups to file will be stored in a directory per server. On the dataset "zbackup/var/zfsbackup". |
| ># mkdir -p /var/zfsbackup/{bigboy,fire,firebox,jacup} | | ># mkdir -p /var/zfsbackup/{aap,noot,mies} |
|
| |
|
| === To disk. === | | === To disk. === |
| Line 27: |
Line 26: |
|
| |
|
| If the dataset exists and needs to be deleted first use: | | If the dataset exists and needs to be deleted first use: |
| ># zfs destroy zbackup/var/zfsbackup/[hostname] | | ># zfs destroy zbackup/var/zfsbackup/[hostname] |
|
| |
|
| Make sure there is a dataset on the backup server for each server. That will be the destination for the streamed backups. | | Make sure there is a dataset on the backup server for each server. That will be the destination for the streamed backups. |
| ># zfs create -o mountpoint=/var/zfsbackup/[hostname] zbackup/var/zfsbackup/[hostname] | | ># zfs create -o mountpoint=/var/zfsbackup/[hostname] zbackup/var/zfsbackup/[hostname] |
| Then create a dataset for each data set to be received | | Then create a dataset for each data set to be received |
| ># zfs create -o mountpoint=/var/zfsbackup/[hostname][dataset] zbackup/var/zfsbackup/[hostname][dataset] | | ># zfs create -o mountpoint=/var/zfsbackup/[hostname][dataset] zbackup/var/zfsbackup/[hostname][dataset] |
|
| |
|
| For jacup that will be: | | For aap that will be: |
| ># zfs destroy -r zbackup/var/zfsbackup/firedoor | | ># zfs destroy -r zbackup/var/zfsbackup/aap |
|
| |
|
| Create the mount points for the host root datasets first | | Create the mount points for the host root datasets first |
| ># mkdir -p /var/zfsbackup/{bigboy,fire,jacup}/zroot | | ># mkdir -p /var/zfsbackup/{aap,noot,mies}/zroot |
| The create
| |
| Then create the datasets for the hosts. | | Then create the datasets for the hosts. |
| ># zfs create -o mountpoint=/var/zfsbackup/bigboy zbackup/var/zfsbackup/bigboy | | ># zfs create -o mountpoint=/var/zfsbackup/aap zbackup/var/zfsbackup/aap |
| ># zfs create -o mountpoint=/var/zfsbackup/fire zbackup/var/zfsbackup/fire | | ># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot |
| ># zfs create -o mountpoint=/var/zfsbackup/firebox zbackup/var/zfsbackup/firebox | | ># zfs create -o mountpoint=/var/zfsbackup/mies zbackup/var/zfsbackup/mies |
| ># zfs create -o mountpoint=/var/zfsbackup/poud zbackup/var/zfsbackup/poud
| | |
| ># zfs create -o mountpoint=/var/zfsbackup/jacup zbackup/var/zfsbackup/jacup
| |
|
| |
|
| For firebox on jacup the sequence would be | | For noot the sequence would be |
| ># zfs destroy -r zbackup/var/zfsbackup/firebox@zfirebox2001101319 | | ># zfs destroy -r zbackup/var/zfsbackup/noot@znoot2001101319 |
| ># zfs destroy -r zbackup/var/zfsbackup/firebox | | ># zfs destroy -r zbackup/var/zfsbackup/noot |
| ># zfs create -o mountpoint=/var/zfsbackup/firebox zbackup/var/zfsbackup/firebox | | ># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot |
|
| |
|
| == Create snapshot == | | == Create snapshot == |
| Line 67: |
Line 64: |
| == Test send snapshot to google drive. == | | == Test send snapshot to google drive. == |
| == Send / Receive backup server zroot backup. == | | == Send / Receive backup server zroot backup. == |
|
| |
| == ZFS Backup per host ==
| |
|
| |
| *[[fire ZFS Backup]]
| |
| *[[firebox ZFS Backup]]
| |
| *[[poud ZFS Backup]]
| |
| *[[bigboy ZFS Backup]]
| |
|
| |
| == ZFS Backup DRAFT ==
| |
|
| |
| ZFS Backup
| |
|
| |
|
| |
| For bigboy zroot to file
| |
|
| |
| 2 Create snapshot on bigboy.
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zroot | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zroot@bigboy_zroot2001201454
| |
|
| |
| 3 Set backup server jacup to Receive snapshot to file.
| |
| ># mkdir -p /var/zfsbackup/bigboy/zroot2001201454
| |
| ># cd /var/zfsbackup/bigboy/zroot2001201454
| |
| ># nc -l 9876 | pv -p | split -a 4 -b 250m
| |
| This produces files named x???? with size of 250mb.
| |
|
| |
| 4 Send snapshot to backup server
| |
| For host bigboy that will be:
| |
| ># zfs send -R zroot@bigboy_zroot2001201454 | bzip2 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
| 5 Rename files to include backup name
| |
| Then rename the generic files to include the backup name with:
| |
| ># for file in x* ; do mv $file bigboy_zroot2001201454.$file; done
| |
|
| |
|
| |
| For poud zpoud to file
| |
|
| |
| 2 Create snapshot on poud.
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zpoud | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zpoud@zpoud2001201625
| |
|
| |
| 3 Set backup server jacup to Receive snapshot to file.
| |
| ># screen
| |
| ># mkdir -p /var/zfsbackup/poud/zpoud2001201625
| |
| ># cd /var/zfsbackup/poud/zpoud2001201625
| |
| ># nc -l 9876 | pv -p | split -a 4 -b 250m
| |
| This produces files named x???? with size of 250mb.
| |
|
| |
| 4 Send snapshot to backup server
| |
| For host bigboy that will be:
| |
| ># zfs send -R zpoud@zpoud2001201625 | bzip2 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
| 5 Rename files to include backup name
| |
| Then rename the generic files to include the backup name with:
| |
| ># for file in x* ; do mv $file zpoud2001201625.$file; done
| |
|
| |
|
| |
|
| |
| For zfire to file
| |
| Note we zip here on the server because of the limited resources on the firewall
| |
|
| |
| 2 Create snapshot on fire.
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zfire | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zfire@zfire2001201930
| |
|
| |
| 3 Set backup server jacup to Receive snapshot to file.
| |
| ># mkdir -p /var/zfsbackup/fire/zfire2001201930
| |
| ># cd /var/zfsbackup/fire/zfire2001201930
| |
| ># screen
| |
| ># nc -l 9876 | pv -p | bzip2 | split -a 4 -b 250m
| |
| This produces files named x???? with size of 250mb.
| |
|
| |
| 4 Send snapshot to backup server
| |
| ># screen
| |
| ># zfs send -R zfire@zfire2001201930 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
| 5 Rename files to include backup name
| |
| Then rename the generic files to include the backup name with:
| |
| ># for file in x* ; do mv $file zfire2001201930.$file; done
| |
|
| |
|
| |
|
| |
|
| |
| For zfirebox to file
| |
| Note we zip here on the server because of the limited resources on the firewall
| |
|
| |
| 2 Create snapshot on fire.
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zfirebox | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zfirebox@zfirebox2001201925
| |
|
| |
| 3 Set backup server jacup to Receive snapshot to file.
| |
| ># mkdir -p /var/zfsbackup/firebox/zfirebox2001201925
| |
| ># cd /var/zfsbackup/firebox/zfirebox2001201925
| |
| ># screen
| |
| ># nc -l 9876 | bzip2 | pv -p | split -a 4 -b 250m
| |
| This produces files named x???? with size of 250mb.
| |
|
| |
| 4 Send snapshot to backup server
| |
| ># screen
| |
| ># zfs send -R zfirebox@zfirebox2001201925 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
| 5 Rename files to include backup name
| |
| Then rename the generic files to include the backup name with:
| |
| ># for file in x* ; do mv $file zfirebox2001201925.$file; done
| |
|
| |
|
| |
| For bigboy zdata to disk
| |
|
| |
| 2 Create snapshot on bigboy.
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zdata | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zdata@bigboy_zdata2001211004
| |
|
| |
| 3 Set backup server jacup to Receive snapshot to disk.
| |
| ># screen
| |
| ># nc -l 9876 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/bigboy/zdata
| |
|
| |
|
| |
| 4 Send snapshot to backup server
| |
| ># screen
| |
| ># zfs send -R zdata@bigboy_zdata2001211004 | bzip2 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
|
| |
|
| |
| 3 Set backup server to Receive snapshot to disk.
| |
| The same command is used for both the base and the incremental.
| |
| First go to screen so you can detach from the session if it takes along time.
| |
| ># screen
| |
| In screen
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/[hostname]/[dataset]
| |
| To receive the root of host bigboy that will be:
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/bigboy/zroot
| |
| To receive the root of host firedoor that will be:
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/firedoor/zroothit
| |
| To receive the root with the hostname in the zpool for host firebox that will be:
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
|
| |
| mkdir -p /var/zfsbackup/fire/
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| 2 Create snapshot.
| |
| ># zfs snapshot zroot@[hostname]_zroot[yymmddhhmm]
| |
|
| |
| For host bigboy that will be:
| |
| Remove the old snapshots first
| |
| ># for f in `zfs list -H -rt snapshot zroot | cut -f 1`; do zfs destroy -nvf $f; done
| |
| Then create the new snapshot:
| |
| ># zfs snapshot -r zroot@bigboy_zroot2001201454
| |
|
| |
| For host firedoor that will be:
| |
| ># zfs snapshot -r zroothit@firedoor_zroothit2001041904
| |
| Or when the zroot has the host name z[host]. use
| |
| ># zfs snapshot -r z[host]@z[host]2001041904
| |
| For host jacup that will be:
| |
| ># zfs snapshot -r zroot@jacup_zroot2001201010
| |
| For host firebox that will be:
| |
| ># zfs snapshot -r zfirebox@zfirebox2001182237
| |
| For host firebox that will be:
| |
| ># zfs snapshot -r zfirebox@zfirebox2001182237
| |
| For host firebox that will be:
| |
| ># zfs snapshot -r zfirebox@zfirebox2001182237
| |
|
| |
|
| |
|
| |
| 3 Set backup server to Receive snapshot to disk.
| |
| The same command is used for both the base and the incremental.
| |
| First go to screen so you can detach from the session if it takes along time.
| |
| ># screen
| |
| In screen
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/[hostname]/[dataset]
| |
| To receive the root of host bigboy that will be:
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/bigboy/zroot
| |
| To receive the root of host firedoor that will be:
| |
| ># nc -l 9999 | bunzip2 | pv -p | zfs recv zbackup/var/zfsbackup/firedoor/zroothit
| |
| To receive the root with the hostname in the zpool for host firebox that will be:
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
|
| |
| mkdir -p /var/zfsbackup/fire/
| |
| ># nc -l 9876 | pv -p | zfs recv zbackup/var/zfsbackup/firebox/zfirebox
| |
|
| |
| 3 Set backup server to Receive snapshot to file.
| |
|
| |
|
| |
|
| |
| 4 Send snapshot to backup server
| |
| If base backup use:
| |
| ># zfs send -R zroot@[hostname]_zroot[yymmddhhmm] | bzip2 | nc -w 5 [dns backup server] 9999
| |
| If manual add pv to see activity.
| |
| ># zfs send -R zroot@[hostname]_zroot[yymmddhhmm] | bzip2 | pv -p | nc -w 5 [dns backup server] 9999
| |
|
| |
|
| |
| For host firedoor that will be:
| |
| ># zfs send -R zroothit@firedoor_zroothit2001041026 | bzip2 | pv -p | nc -w 5 jacup.sjakio.com 9999
| |
| For host firebox that will be:
| |
| ># zfs send -R zfirebox@zfirebox2001071144 | bzip2 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
| ># zfs send -R zfirebox@zfirebox2001182237 | pv -p | nc -w 5 jacup.sjakio.com 9876
| |
|
| |
|
| |
|
| |
|
| |
| 5 Send backup server snapshot to backup server
| |
| For host jacup there is a special case as we are local. So that will be:
| |
| Create directory for chopped files.
| |
|
| |
| ># mkdir /var/zfsbackup/jacup/zrootATjacup_zroot2001201010.chopped
| |
| ># cd /var/zfsbackup/jacup/zrootATjacup_zroot2001201010.chopped
| |
| ># screen
| |
| ># zfs send -R zroot@jacup_zroot2001201010 | bzip2 | pv -p | split -a 4 -b 250m
| |
|
| |
| 5 Send / Receive backup server zroot snapshot
| |
| Example from Freebsd handbook voor een incremental backup is:
| |
| zfs send -v -i mypool@replica1 mypool@replica2 | zfs receive /backup/mypool
| |
| zfs send zroot/desktop@backup > /backup-desktop.zfs
| |
| ># zfs snapshot -r zroot@[hostname]_zroot[yymmddhhmm]
| |
| ># zfs snapshot -r zroot@jacup_zroot2001192218
| |
| ># zfs send -R zroot@jacup_zroot2001192218 | pv -p | bzip2 > /var/zfsbackup/jacup/zrootATjacup_zroot2001192218.bzip2
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| If incremental snapshot use:
| |
| ># zfs send -v -i zroot@[hostname]_zroot[yymmddhhmm(T-1)] [hostname]_zroot[yymmddhhmm(T)] | bzip2 | pv -p | nc -v -w5 [dns backup server] 9999
| |
| For big boy that will be:
| |
| ># zfs send -v -i zroot@[hostname]_zroot[yymmddhhmm(T-1)] [hostname]_zroot[yymmddhhmm(T)] | bzip2 | pv -p | nc -v -w5 [dns backup server] 9999
| |
|
| |
|
| |
|
| |
| 4 Test send snapshot to google drive
| |
| For testing we can use the command sequence. -a is the suffix length. Max is 13 we use 12 as we will not have file names just the suffix -b is the block size in bytes, set as 100m is 100 megabytes.
| |
| ># cd /var/zfsbackup/rclone
| |
| ># zfs send -R zbackup/var/backup/srvr@srvr_zroot1912131246 | bzip2 | split -a 12 -b 100m
| |
| ># ls
| |
| total 1064262
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:48 xaaaaaaaaaaaa
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:49 xaaaaaaaaaaab
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:49 xaaaaaaaaaaac
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:50 xaaaaaaaaaaad
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:50 xaaaaaaaaaaae
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:50 xaaaaaaaaaaaf
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:51 xaaaaaaaaaaag
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:51 xaaaaaaaaaaah
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:52 xaaaaaaaaaaai
| |
| -rw-r--r-- 1 root wheel 104857600 Dec 15 12:52 xaaaaaaaaaaaj
| |
| -rw-r--r-- 1 root wheel 40527524 Dec 15 12:52 xaaaaaaaaaaak
| |
| Restore from this can be done with:
| |
| ># cat x* | bunzip2 | pv -p | zfs recv zbackup/var/backup/restore_srvr
| |
|
| |
|
| |
|
| |
| 6 Send backup to google drive
| |
| zfs send -R zbackup/var/zfsbackup/jacup@jacup_zroot1912151310 | bzip2 | split -a 12 -b 100m
| |
| ># zfs send -R zbackup/var/zfsbackup/bigboy/zroot@bigboy_zroot1912152022 | bzip2 | \
| |
| split -a 12 -b 100m | pv -p | rclone rcat
| |
|
| |
|
| |
| ># zfs send -R zroot/poudriere/data/packages@jacup_zroot1912151310 | bzip2 | split -a 12 -b 50m | pv -p | rclone rcat gdrive-zfs:bigboy_zroot1912152022.zfs --config /usr/local/etc/rclone.conf
| |
|
| |
| For bigboy that would be
| |
| First create a temp directory in:
| |
| /var/zfsbackup/tmprclone
| |
| ># cd /var/zfsbackup/tmprclone
| |
| ># mkdir bigboyzrt
| |
| ># cd bigboyzrt
| |
| Then create the files in this directory:
| |
| ># zfs send -R zbackup/var/zfsbackup/bigboy/zroot@bigboy_zroot1912152022 | bzip2 | split -a 12 -b 250m
| |
| Then send the files with rclone to gdisk, -P shows the progress zo we can see what is happening.
| |
| ># rclone copy bigboyzrt secret:bigboy_zroot1912152022 -P --config /usr/local/etc/rclone.conf
| |
|
| |
| For jacup that would be:
| |
| ># cd /var/zfsbackup/tmprclone
| |
| ># mkdir jacupzrt
| |
| ># cd jacupzrt
| |
| ># zfs send -vR zbackup/var/zfsbackup/jacup/zroot@jacup_zroot1912151310 | bzip2 | split -a 12 -b 250m
| |
| ># rclone copy jacupzrt secret:jacup_zroot1912151310 -P --config /usr/local/etc/rclone.conf
| |
|
| |
|
| |
|
| |
| 7 Receive backup from google drive
| |
| ># mkdir recvbigboyzrt
| |
| ># cd recvbigboyzrt
| |
| ># rclone copy secret:jacup_zroot1912151310 jacupzrt -P --config /usr/local/etc/rclone.conf
| |
|
| |
|
| |
| 8 Restore backup
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| <hr>
| |
| <p style="text align:left;">Previous [[Poudriere setup]]
| |
| <span style="float:right;">Return [[Freebsd Knowledge Base]]</span></p>
| |
| <center> Up [[Freebsd Knowledge Base]]</center>
| |
| <hr>
| |
Previous Poudriere setup
Next Firewall Switch
ZFS Backup Synopsis
We are going to use ZFS to backup disk.
We could use ZFS send and ZFS receive to write the dataset snapshot to the backup server disks. This will however cause problems with mount points for backups of the root file system.
We therefore use ZFS send to a file for backups of root file systems.
We also ensure that those ZFS pools which contain data are named unique within the landscape., i.e. zdata for the file-server data pool and zbackup for the backup server data pool.
Backups are send of the LAN using nc (netcat). We are not using compression as we have a fast 10gig LAN and LZ4 compression is used on all disks.
There are 4 general steps as listed below:
1 Prerequisites
Prerequisites
There are different requirements for backup storage using storage to file or storage to disk. For file we just need a files system, for disk we need a unique dataset.
To file.
ZFS backups to file will be stored in a directory per server. On the dataset "zbackup/var/zfsbackup".
># mkdir -p /var/zfsbackup/{aap,noot,mies}
To disk.
If the dataset exists and needs to be deleted first use:
># zfs destroy zbackup/var/zfsbackup/[hostname]
Make sure there is a dataset on the backup server for each server. That will be the destination for the streamed backups.
># zfs create -o mountpoint=/var/zfsbackup/[hostname] zbackup/var/zfsbackup/[hostname]
Then create a dataset for each data set to be received
># zfs create -o mountpoint=/var/zfsbackup/[hostname][dataset] zbackup/var/zfsbackup/[hostname][dataset]
For aap that will be:
># zfs destroy -r zbackup/var/zfsbackup/aap
Create the mount points for the host root datasets first
># mkdir -p /var/zfsbackup/{aap,noot,mies}/zroot
Then create the datasets for the hosts.
># zfs create -o mountpoint=/var/zfsbackup/aap zbackup/var/zfsbackup/aap
># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot
># zfs create -o mountpoint=/var/zfsbackup/mies zbackup/var/zfsbackup/mies
For noot the sequence would be
># zfs destroy -r zbackup/var/zfsbackup/noot@znoot2001101319
># zfs destroy -r zbackup/var/zfsbackup/noot
># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot
Create snapshot
It is best to remove older snapshots when a full backup is made, use:
># for f in `zfs list -H -rt snapshot [zroot name] | cut -f 1`; do zfs destroy -nvf $f; done
Then create the snapshot with the date and time as part of the name. Format used is:
># zfs snapshot -r [zroot name]@[host name]YYMMDDhhmm
Set backup server to Receive snapshot.
to disk.
to file.
Send snapshot to backup-server.
Test send snapshot to google drive.
Send / Receive backup server zroot backup.