Главное меню
Ссылки
RSS трансляции
Наши новости могут транслироваться, используя rss.
rss1.0
rss2.0
rdf
FAQ
 FAQ #77
Back to Categories    Print this FAQ  Send a link to this FAQ to a friend pdf
Бекап Freebsd с файловой системой ZFS
Оригинал тут


Full system backups for FreeBSD systems using ZFS
49 Replies

Assuming you have created your ZFS FreeBSD system using the instructions on my site, here is how to do full system backups to an extra attached disk.

You can adjust these instructions if you need to store the backup remotely – but they are out of scope of this post.

First, in case you haven’t already… here is how to format/dev/da1 as a dedicated ZFS backup drive. You can configure the backup drive however you want (it doesn’t even need to be ZFS-based) but you will also have to adjust these instructions accordingly to restore too.

gpart destroy -F da1
dd if=/dev/zero of=/dev/da1 bs=1m count=128
zpool create zbackup /dev/da1
zfs set mountpoint=/backup zbackup

The above will destroy any existing data on /dev/da1, and create a ZFS filesystem which is mounted at /backup.

Next we snapshot all filesystems under zroot and send them to a gzip’d file on the backup medium. We then release the snapshot:

zfs snapshot -r zroot@backup
zfs send -Rv zroot@backup | gzip > /backup/full-system-backup.zfs.gz
zfs destroy -r zroot@backup

This is all you need to do on the live system.

If the worst happens, and you need to restore to a new system (or a freshly formatted one)…

Firstly, follow the original instructions up to and including the line “zfs set checksum=fletcher4 zroot”.

Next, we import the backup ZFS drive and mount it – then we use ZFS receive to restore the filesystem and all its dependants:

zpool import -f zbackup
zfs set mountpoint=/boot/zfs/backup zbackup
zfs mount zbackup
gunzip -c /boot/zfs/backup/full-system-backup.zfs.gz | zfs receive -vdF zroot

Now we need to unmount the backup drive, and mount the original root ZFS so we can re-create the cache file (the system will not boot without the correct cache file):

zpool export zbackup
zfs set mountpoint=/boot/zfs/zroot zroot
cd /boot/zfs
zpool export zroot && zpool import zroot
cp /boot/zfs/zpool.cache /boot/zfs/zroot/boot/zfs/zpool.cache
zfs unmount -a
zfs set mountpoint=legacy zroot
reboot

This will reboot the system in its original state. If you want to re-mount your backup medium, it will need to be re-imported and mounted:

zpool import -f zbackup
zfs set mountpoint=/backup zbackup

That’s all there is to it. A fully working disaster recovery solution.
Views 867 (Unique 471)
Member Rating : Not yet rated  
FAQ Posted by vampyr
Info Created: Wednesday 04 July 2018 - 15:11:57
Last Updated: Wednesday 04 July 2018 - 15:11:57
 
РадиоЭлектроника
Поиск Vampyr`s House!
Copyright © 1999-2014, Igor Muraviov. Все авторские права принадлежат их владельцам ( в случае указания) или владельцу сайта, если автор не указан.
Копирование материалов с сайта возможно только в случае размещения ссылки на первоисточник.
Protected by Copyscape DMCA Plagiarism Check