Cpanel backup using NFS
From SolusVM
Contents |
Overview
This is for people using Cpanel/WHM as a VPS and try to run cpbackup daily to backup data to a remote NFS.
Build a NFS server
First you got to have a NFS server installed. Youu need 2 packages to run ur NFS:
nfs-utils
portmap
I don't want spend time on howto install a NFS, so I gonna assume you have done that. Now, check if you have portmap:
ps ax |grep portmap
and check if this command work:
showmount -e
if both work, then you can proceed to next step, config NFS client.
NFS client Host node
You will need to take a look at this page:http://wiki.openvz.org/NFS
NFS client vps
On the vps which you already installed Cpanel on, you need to do some setting to enable the nfs:
vzctl set 101 --features "nfs:on" --save
the 101 is the CTID of your vps, if you are not sure, you can type: vzlist in the node's shell to see what it is.
After you did above, you now need to restart the vps.
Now, you should be able to fins nfs in this file:/proc/filesystems, and you can test your nfs client setting by mount a NFS server, type:
mount -t nfs 192.168.100.111:/backup/nfs /remote-bk
Note: 192.168.100.111 should replace to your IP address, /backup/nfs should be the NFS's directory prepare to be mounted, and /remote-bk is the local directory you want to be called, and you need to create that directory but noo sub-dir in it.
Auto Mount
Check if your system got autofs by type:
ps ax |grep auto
You should be able to see something like this:
9945 ? Ssl 0:00 automount
If not, then, install it by type: yum install autofs
After installed, edit /etc/auto.master and /etc/auto.nfs
auto.master is a master control file control how autofs works.
nano /etc/auto.master
Now, we need to add a line like this on the last line:
/remote-bk /etc/auto.nfs --timeout 300
300 means if after 300 seconds not using it will closed.
All right! Now we need to create a file called /etc/auto.nfs and add a line like below:
nfs -rw,bg,soft 192.168.100.70:/backup/nfs
OK, Save it, restart autofs, and run the funny part by:
cd /remote-bk/nfs
and
df
you should see probably these:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/simfs 209715200 37371840 172343360 18% /
none 614400 4 614396 1% /dev
192.168.100.70:/backup/nfs
480719072 160825888 295473984 36% /remote-bk/nfs
See! you automatically mount a remote filesystem, now, cd back to somewhere else and wait for 300 seconds, and type df again, you won't see the remote filesystem again cause it unmounted already.
Every time you edit the config file, you will need to restart it by:
service autofs restart
After all done, you should be able to see your nfs directory and files on the remote everytime when you switch to the nfs directory.
