# Procedure for backup and restore



## balanga (Nov 30, 2016)

Can anyone provide a pointer to doing backups of data on a remote VPS FreeBSD system and how would I go about recovering that data in the event of a system crash?


----------



## Nat_RH (Dec 3, 2016)

I use Tarsnap and some periodic scripts.  Works nicely as a secure backup.


----------



## balanga (Dec 5, 2016)

getopt said:


> See what wblock@ has on his homepage: http://www.wonkity.com/~wblock/docs/html/backup.html
> 
> These sections have what you are looking for:
> 
> ...



Thanks for the suggestions. What I'm not really sure about is what to backup. I guess I don't really need to backup the base operating system because that can always be re-installed. What I'm confused about is where are 'my files' stored? ie the data and any programs/configuration files which I have installed after the base FreeBSD install.


----------



## Beastie (Dec 5, 2016)

You didn't mention if you are using FreeBSD as a server or as a desktop. I suggest you look at hier(7) if you're not already familiar with the system's hierarchy.

If you've modified the configuration files of system or third-party applications you should start looking in /etc and /usr/local/etc. User files and configuration are in /home (may be just a directory or a separate partition). Databases are in /var/db.

By the way, in case you'll be using dump(8), you can exclude directories (such as /usr/src) using the *nodump* flag (check chflags(1) and dump(8) for more information).


----------



## phoenix (Dec 5, 2016)

balanga said:


> Thanks for the suggestions. What I'm not really sure about is what to backup. I guess I don't really need to backup the base operating system because that can always be re-installed. What I'm confused about is where are 'my files' stored? ie the data and any programs/configuration files which I have installed after the base FreeBSD install.



The base OS is so tiny (a couple of GB at most) and changes so rarely, why wouldn't you just backup everything?  Recovery is much simpler that way.  Just boot off a LiveCD, format the drives, restore the backups, and reboot.  No muss, no fuss, no worrying about missing a file somewhere, no worrying about getting things setup and installed the same way.

Otherwise, you get into the situation where you need to install the OS, then install all the programs, then restore the config file, then restore the data, and hope you didn't miss anything in the backups, then reboot and hope everything works.

Just do a full system backup, and be done with it.    Rsync and ZFS are wonderful things for doing just this.


----------



## freebuser (Dec 5, 2016)

Trust me.. you won't realize the advantage of having the OS backed up until you start all the configs and other setups from scratch again.

Having the full backup makes sure the restore is painless.

I backup (dump) /, /usr, /var (all in separate partitions) into compressed files along with my data which is in zfs system into two tapes and keep one at home and another at office.


----------



## balanga (Dec 6, 2016)

phoenix said:


> The base OS is so tiny (a couple of GB at most) and changes so rarely, why wouldn't you just backup everything?  Recovery is much simpler that way.  Just boot off a LiveCD, format the drives, restore the backups, and reboot.  No muss, no fuss, no worrying about missing a file somewhere, no worrying about getting things setup and installed the same way.



The problem is that FreeBSD is running under VMWare on a remote VPS which I have no physical access to. I can access it via a vSphere client but have no idea about what I can actually do with this access.


----------



## phoenix (Dec 6, 2016)

You don't need physical access to it for the backups.  You can just run rsync-over-ssh and copy the data off to wherever (another VM, a USB disk attached to your home computer, etc).  Or, if using ZFS in the VM, just use "zfs send" for each filesystem.

For recovery, you use the vSphere client to connect an ISO image file of a LiveCD (like mfsBSD) and use that to boot (the vSphere client gives you "physical access" to the console as if you were sitting in front of physical system).  Partition the virtual disks, create the filesystems, mount the filesystems, and then use rsync to copy the data back from the backups to the disks.  Update the boot blocks, and reboot into the VM.  (Glossing over a few details, but that's the gist of it.)


----------



## balanga (Dec 7, 2016)

phoenix said:


> You don't need physical access to it for the backups.  You can just run rsync-over-ssh and copy the data off to wherever (another VM, a USB disk attached to your home computer, etc).  Or, if using ZFS in the VM, just use "zfs send" for each filesystem.
> 
> For recovery, you use the vSphere client to connect an ISO image file of a LiveCD (like mfsBSD) and use that to boot (the vSphere client gives you "physical access" to the console as if you were sitting in front of physical system).  Partition the virtual disks, create the filesystems, mount the filesystems, and then use rsync to copy the data back from the backups to the disks.  Update the boot blocks, and reboot into the VM.  (Glossing over a few details, but that's the gist of it.)



I get the bit about backups, but the recovery part sounds several levels beyond my competance at the moment, so I'll keep this post for reference, and try and work out what I can do from the vSphere console.


----------

