Quite a common setup for people is to use Windows PCs with Linux servers. This configuration allows you to benefit from a stable, standard based and secure server platform which doesn’t burn a whole in your pocket while letting the users continue operating the tools they know. A usual solution is to run samba on a Linux server which can then act as a Windows Domain Controller. This allows Windows clients to log on to the domain and access file and printer shares on the server. Of course you can also have Linux clients integrated in that configuration but this is not going to be the subject of this article.
Usually the Windows PCs store the user profiles on the server. Backing the user profiles can then be done as part of backing up the whole server. You might have some other files though which are not part of the user profile. Backing up these files can be easily done using rsnapshot and autofs.
We’ll use autofs to setup file sharing between the Windows PCs and the Linux server. This is especially useful for computers which are not always connected to the network like laptops, although people do turn off their desktops as well from time to time. What autofs allows us to do is to activate file sharing only when it’s needed for the purpose of doing a backup.
Performing the actual backup will be done using rsnapshot. This tool, which I already mentioned in a previous post, allows space efficient backups which are stored incrementally while offering ease of access usually associated with full backups.
Before setting up autofs we need to create a network share on the Windows PC. Remember the user and the password since we’ll need them later on. In this article I’m going to assume the user name is backup and the password is secret but you should use something more difficult to guess depending on your security requirements. I’m also assuming the Windows domain is called company. On the Linux server you then need to make sure you’ve got autofs installed. Installation of autofs is not covered here but usually it’s as simple as executing yum install autofs. You need to edit /etc/auto.master file and add this line
/smb /etc/auto.windows --timeout=60
Then you create the file /etc/auto.windows containing the following, in a single line:
<share> -fstype=smbfs,
credentials=/etc/auto.windows.<credentials file>,
uid=<user>,gid=<group>,
fmask=0755,dmask=0755 ://<windows PC>/<network share>
This must be written on a single line, with no separating spaces starting from -fstype to dmask=0755
<share> is the name of directory where you want to mount the network share from Windows PC.
/etc/auto.windows.<credentials file> is the name of file where you store the user name and password needed to access the network share on Windows PC. In our case it will look like this:
username = backup
password = secret
domain = company
After these preparations it’s time to tell the autofs daemon about these changes by executing service autofs reload or a corresponding command. You should be able now to see that the network share gets automatically mounted when you execute ls /smb/<share>. After 60 seconds the share will be unmounted.
Now the last part - setting up rsnapshot. Just follow the instructions for rsnapshot as if the directory /smb/<share> was local. Thanks to autofs, rsnapshot doesn’t need to know that it’s really on a different computer running Windows. Remember to set up a cron job if this is your first time you’re using rsnapshot.
That’s it. You’ve configured an automatic backup of a Windows computer using Linux. You can repeat this procedure on further Windows clients.
P.S. Another approach is described here but it has the drawback that it requires installing additional software on the Windows PCs.
Print This Post



Post a comment