So I have some SUSE 11 Enterprise servers that I need to backup. I'd just tar the files and copy them somewhere. How do I automate copying these tarballs to a Windows share?
[B]some ideas:[/B]
"crontab -e" is a simple interface for cron, it will run anything it reads in that file.
why not create a bash script that tars a folder and copies it to a window share?
something like:
[code]
* 10 * * * /home/<username>/backup-dir/backupscript.sh
[/code]
(the above will run the script every 10 hours). you can [URL="http://www.nncron.ru/help/EN/working/cron-format.htm"]change[/URL] the time to anything you want.
[B]create [/B]a folder in your home directory called backup-dir
create a file called backupscript.sh in backup-dir
then in "backupscript.sh" put:
[code]
cd /home/<username>/backup-dir
# the above cd's into the working directory
tar -cvzpf backup-$(date '+%m%d%y%H%M%S').tar.gz /folder/to/backup /another/folder /also/a/file.txt
# the above tars a specific folder(s), file(s)
cp $(ls -v backup-* | tail -n 1) /path/to/winshare/
#above copies backup with highest date to winshare
[/code]
you might need to modify the script, to mount the share, depending on your setup.
Well I got the mounting down...just did mount -t cifs //pathto/share /mnt/mountpoint
So I need scheduling...and I need the above mount command to execute when the server reboots so the mount point ALWAYS exists.
yeah, you can do it in fstab or just put the 'mount -t cifs //pathto/share /mnt/mountpoint' in the script above. So it'll do it everytime the script is run.
[code]
cd /home/<username>/backup-dir
# the above cd's into the working directory
[B]mount -t cifs //pathto/share /path/to/winshare/[/B]
# above mounts the share
tar -cvzpf backup-$(date '+%m%d%y%H%M%S').tar.gz /folder/to/backup /another/folder /also/a/file.txt
# the above tars a specific folder(s), file(s)
cp $(ls -v backup-* | tail -n 1) /path/to/winshare/
#above copies backup with highest date to winshare
[/code]
[QUOTE=faze;34644147]Well I got the mounting down...just did mount -t cifs //pathto/share /mnt/mountpoint
So I need scheduling...and I need the above mount command to execute when the server reboots so the mount point ALWAYS exists.[/QUOTE]
You can put the mount into /etc/fstab
It should look something like this I belive.
[code]
//pathto/share /mnt/mountpoint cifs user=whatever,password=whatever 0 0
[/code]
As for scheduling, depending on the cron you use (fcron, dcron, vixie-cron, whatever), you could use either crontab -e like pygar said, or you may have to copy that bash script into /etc/cron.daily (or cron.hourly, cron.monthly, whatever you want).
For the auto mounting...can't I make a .sh script to run the mnt command mentioned earlier and just set it up to start when the server boots from the GUI? Or does it have to be manually entered into /etc/fstab?
^^^ you can do it as i suggested.
[QUOTE=pygar;34685475]^^^ you can do it as i suggested.[/QUOTE]
And my way?
You can do it either way.
/etc/fstab is just considered more standard.
If you add the noauto option to your line in fstab it won't mount automatically.
Then, you can do [code]mount /mnt/path/to/mountpoint/[/code]
without having to specify a billion options
Sorry, you need to Log In to post a reply to this thread.