Jump to content

Recommended Posts

Posted

Hi all,

 

not sure if this should be here or in the scripts section but here goes.

 

I have to backup a linux server each night and would like to acheive the following:

 

A full copy backup of the /usr/var/www/*.* folder

A full copy backup of each mysql database on the server

A full copy backup of the /usr/var/moodledata folder

 

The contents of the above should be copied into /var/backups/[date]/ with the file structure of each remaining intact and an additional folder being created for the MySQL_DataBackup.

 

Once the above has completed I need it to be FTP'd of to another server which will then be burned to DVD hopefully.

 

Any pointers on where to start or if anyone has anything like this would be great.

Posted

You could look into using rsync for synchronizing your "live" data with your "backup" data on another server. You can use rsync with a cronjob to automatically backup your files each night and get them transferred over to your backup server.

 

Regarding your MySQL database you could either dump the database and backup the copy, sync/replicate the database or a number of other options. Sorry I don't really have any information links to hand right at this moment in time, but if any come up I'll be sure to post them. :)

 

Best Regards,

Posted

Something like this should do it.

 

mkdir /var/backups/`date +%Y-%m-%d%n`

cd /var/backups/`date +%Y-%m-%d%n`

 

cp -R /usr/var/www .

cp -R /usr/var/moodledata .

 

 

mkdir ./MySQL_DataBackup

mysqldump -u root --password=doodah --all-databases > ./sql-`date +%Y-%m-%d%n`.sql

gzip sql-`date +%Y-%m-%d%n`.sql

 

mount -t smbfs -o username="servername\username",password=doodahpassword //servername/share /var/backups/link2backupserver

 

cp -R /var/backups/`date +%Y-%m-%d%n` /var/backups/link2backupserver

Posted

@kmount:

 

If i am reading your script right:

 

1 - Make the backup directory

2 - Change into the directory

3 - Copy /usr/var/www/*.* while maintaining structure

4 - Copy /usr/var/moodledata/*.* while maintaining structure

5 - Make the MySQL_Backup folder

6 - Dump the sql databases into the above folder (question to follow)

7 - Mount to a file share with relevant permissions on a windows box

8 - Copy the full backup folder over.

 

Am i far off??

 

Question regarding step 6, is this a single file dump or are they seperate for each database (i have 7 in total)

 

How would you schedule this to run each night??

Posted

Yup, you're correct.

 

If you want to do dump the backup of each database individually you can, for example.

 

mysqldump -u root --password=doodah mydb1 > ./mydb1-`date +%Y-%m-%d%n`.sql

mysqldump -u root --password=doodah mydb2 > ./mydb2-`date +%Y-%m-%d%n`.sql

mysqldump -u root --password=doodah mydb3 > ./mydb3-`date +%Y-%m-%d%n`.sql

 

The gzip line just compresses them for the sake of sanity/space.

Posted

Ahh cool that makes sense.

 

What about running as a scheduled script each night, what would be the best way of doing this??

 

You will have to forgive me on this as I am no *nix guru but need to have some sort of backup plan in place and seeing as this is such a key server, well I guess you understand.

Posted

On linux, sheduled tasks go by the name of cronjob/tabs.

 

So, as root you'd need to do the following:

 

Log in as root (since you're needing to grab files from everywhere, otherwise not a good idea).

 

Put the content of the script into /root/doBackup.sh

chmod it 700 so its executable by root but not readable by anyone else

Type crontab -e which will drop you into a text editor where you put the entry below.

 

30 23 * * * sh /root/doBackup.sh

 

Will run it at 23:30hrs each evening.

 

Have a look here for more info.

 

Hope this helps.

  • Thanks 1
Posted

Just a quick one, what do they following lines do:

 

/var/backups/link2backupserver

 

just trying to work out what link2backupserver is?

Posted
Your backup device needs to be accessable from the script. In this case, it needs to be mounted in the directory you've mentioned. It depends on what you backup device actually is though on how to do this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...