Back up all domains and SQL?


#1

how do you backup all domain files and SQL with one command or something simple as backup up the DB’s gets complicated now that i have 10! since i have to do it one by one.

Thanks in advance.


#2

Check out this article in the wiki. It should help you accomplish exactly what you’re looking for.

Automatic Backup

-Matttail


#3

what do i name the file that i upload with the information?
crontab.txt

and once i upload it I don’t need to to anythign it will automatically execute on time set?


#4

I’m a little unclear about wat you’re asking. I you want, you can put the lines for the crontab in a text file, upload it and then from ssh type:
crontab crontab.txt

That will take your text file and make it the crontab (overwritting anything you might allready have there)

You can also just edit the crontab directly from ssh by typing:
crontab -e
and then typing in the lines.

-Matttail


#5

ok do i need multiple mysql.sh or can i make one and just have multiple within it?

like below

#!/bin/bash
mkdir /home/username/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -ppass -h mysql.domain.com db_name > backups/mysql/db_name.$suffix.sql
tar -cf /home/username/backups/archives/mysql_backup.$suffix.tar backups/mysql/*
rm -r backups/mysql/

#!/bin/bash
mkdir /home/username2/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser2 -ppass2 -h mysql2.domain.com db_name > backups/mysql2/db_name.$suffix.sql
tar -cf /home/username/backups/archives/mysql_backup.$suffix.tar backups/mysql/*
rm -r backups/mysql/


#6

Just add multiples like this:

#!/bin/bash
mkdir /home/username/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -ppass -h mysql.domain.com db_name > backups/mysql/db_name.$suffix.sql
mysqldump --opt -uUser2 -ppass2 -h mysql2.domain.com db_name2 > backups/mysql/db_name2.$suffix.sql
mysqldump --opt -uUser3 -ppass3 -h mysql3.domain.com db_name3 > backups/mysql/db_name3.$suffix.sql
tar -cf /home/username/backups/archives/mysql_backup.$suffix.tar backups/mysql/*
rm -r backups/mysql/

-Matttail


#7

I suppose I should follow up on my own post. The method above is what I do. That way all of the mysql databases are in one tar archive. But if you want seperate archives for each database then you could either use sperate scripts or make the one script look somethign like:

#!/bin/bash
mkdir /home/username/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -ppass -h mysql.domain.com db_name > backups/mysql/db_name.$suffix.sql
tar -cf /home/username/backups/archives/mysql_backup.$suffix.tar backups/mysql/db_name.$suffix.sql
mysqldump --opt -uUser2 -ppass2 -h mysql2.domain.com db_name2 > backups/mysql/db_name2.$suffix.sql
tar -cf /home/username/backups/archives/mysql_backup2.$suffix.tar backups/mysql/db_name2.$suffix.sql
rm -r backups/mysql/

As long as this script isn’t running close to midnight, when the date will change, it should work. Keep in mind this isn’t tested, so it might not work. I don’t think that you need to sperate out the dumps as far as the server’s concerned - it’s up to you.

-Matttail


#8

thanks i should be getting all this going this week then!! thanks!