LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Samba and Tar question (https://www.linuxquestions.org/questions/linux-newbie-8/samba-and-tar-question-633771/)

dadrummerray 04-07-2008 05:38 PM

Samba and Tar question
 
Hello Everybody,

I have a Fedora* box running a webserver that i am trying to backup. I have done this on windows but i haven't done too much with linux to know what exactly i need to do.

Here is what i want to accomplish:
1) Create a crontab to run a file every day that will make a tar backup of my webserver folder (/var/www/html)
2) have that same crontab run a dump of my mysql database
3) have the same crontab tar those two files
4) have the same crontab copy the big tar to a backup server to be used for restore later if needed. The server is a windows file server

I have a file that will make backups of the databases and the webserver folder. I am having problems getting fedora core8 to send that tar file to the windows file server. Also, i would like to keep 5 days of backups in case of needing to restore to a previous day or something. This can be done through a rename and copy command (which i can do) but i will need to be mounted to the share in order for that to work. Can anyone offer any help?

Thanks!!

BrianK 04-07-2008 05:50 PM

Code:

#!/bin/bash

cd /var
tar cf backup_dir/www_backup.tar www/html
mysqldump -uuser -ppass db_name > backup_dir/database_backup.sql
cd backup_dir
tar cvjpf backup.`date +%a`.tbz2 www_backup.tar database_backup.sql
cp backup.`date +%a`.tbz2 /windows/share

.. which will end up storing the last 7 days of backups & continuously overwrite anything older than 7 days. Why? because "date +%a" returns a weekday, so the backups will look like backup.Mon.tbz2

it also has the nice side effect of sending you a mail every time it's executed as that last tar is verbose & output from a cron script usually gets emailed to the owner. This is a good way of verifying everything worked.

The type of shell doesn't matter... could be bash, tcsh, sh, whatever you're most familiar with.


All times are GMT -5. The time now is 05:55 PM.