Automated backup of Linux Server to Windows
This tutorial assumes two things:
1) You are sharing a connection via a router or hub. One computer is linux, one is windows.
2) You have samba installed
First, you want to make the linux server be accessable by the windows machine. To do this, edit your smb.conf like so:
....
workgroup = WORKGROUP
....
#Whatever the windows machine static IP is, on the LAN
hosts allow = 192.168.2.100
....
#This is the share you want to map in windows
#in case you ever need to back up windows files to linux
[backup]
comment = Backup
path = /backup
browseable = yes
public = yes
writable = yes
create mask = 0770
directory mask = 0770
[etc]
comment = Etc
path = /etc
browseable = yes
public = yes
writable = yes
create mask = 0770
directory mask = 0770
#assuming you have a soft link to your htdocs in /root, you won't need
#to make another entry for apache's htdocs folder
[root]
comment = root
path = /root
browseable = yes
public = yes
writable = yes
create mask = 0770
directory mask = 0770
.....
Next, you're going to want to make sure each computer can access each other hassle free.
To do this, make an account called 'Guest' on both windows and linux. No password. In /etc/passwd change /bin/bash to /bin/false (or if bin/bash isn't there, add /bin/false at the end line of Guest anyways).
Next, usermod -G root Guest && usermod -G www-data Guest (www-data might be nobody if you use apache2). Now chmod -R 770 /root /etc /var/www (or path to htdocs).
An easier way to do this is a cron task.
crontab -e
* 0 * * * /root/chown-users >> /dev/null 2>&1
In /root/chown-users:
#!/bin/bash
for x in `ls /home`
do
chown -R $x /home/$x
chgrp -R users /home
chmod -R 705 /home
chmod 715 /home
done
chown -R Guest /backup
chmod 700 /backup
chgrp -R root /etc /root /usr/local/apache2/htdocs
chown -R 770 /etc /root /usr/local/apache2/htdocs
In Windows, make sure the Guest account is turned on, and has no password set to it.
Now type 'smbpasswd -a Guest'
When promted for a password, press enter.
Now make a 'Backup.bat' with the following code: