I use BQbackup as well and have written a script that simply runs the CPanel backup script, tars a couple of things and is run by cron when scheduled. and I would be happy to share it.
Would you please? Maybe post it as a tutorial?
Regards,
I use BQbackup as well and have written a script that simply runs the CPanel backup script, tars a couple of things and is run by cron when scheduled. and I would be happy to share it.
#!/bin/sh
#This is a file written to run the CPanel backup utility for each users home directory and then upload it to BQbackup.
#Four weeks of backups will be rotated and kept.
#First rotate/create directories.
( ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com rm -rf week4
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week3 week4
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week2 week3
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week1 week2
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mkdir week1
#This directory is for SQL backups created using [URL="http://sourceforge.net/projects/phpmybackup/"]PHPMyBackupPro[/URL].
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mkdir week1/sqlbu
#Change to home directory. Run Cpanel backup script. Upload to BQbackup. Delete backup file. Repeat as neccessary for each account.
cd /home
/scripts/pkgacct <account1>
scp cpmove-<account1>.tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f cpmove-<account1>.tar.gz
#Tar Apache config. Upload to BQbackup. Delete backup file.
cd /usr/local/apache
tar cf /home/apache-conf.tar.gz conf
scp /home/apache-conf.tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f /home/apache-conf.tar.gz
#Tar shared applications. Upload to BQbackup. Delete backup file.
cd /usr/local/share
tar cf /home/shared-htdocs.tar.gz htdocs
scp /home/shared-htdocs.tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f /home/shared-htdocs.tar.gz
#Change to SQL backup folder. Upload files to BQbackup.
cd /home/sqlbu/export
scp *gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/sqlbu/
)
Dan said:#This is a file written to run the CPanel backup utility for each users home directory and then upload it to BQbackup.
Josh,
Yes you replace <account1> with the first account name and then repeat that section for each additional account.
How can we get this to automatically pull each account and do it? I don't want to sit and edit this every time a new account is added.
Thanks for your help,
cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' |
while read user; do
#Do something useful here
echo "$user"
done
You could either walk the /home directory or parse /etc/passwd.
Code:cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' | while read user; do #Do something useful here echo "$user" done
You'd put whatever code needs a specific username in place of the echo.
#!/bin/sh
#This is a file written to run the CPanel backup utility for each users home directory and then upload it to BQbackup.
#Four weeks of backups will be rotated and kept.
#First rotate/create directories.
( ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com rm -rf week4
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week3 week4
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week2 week3
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mv week1 week2
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mkdir week1
#This directory is for SQL backups created using PHPMyBackupPro.
ssh <bqbackupusername>@<bqbackupusername>.bqbackup.com mkdir week1/sqlbu
#Change to home directory. Run Cpanel backup script. Upload to BQbackup. Delete backup file. Repeat as neccessary for each account.
cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' |
while read user; do
#Do something useful here
cd /home
/scripts/pkgacct "$user"
scp cpmove-"$user".tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f cpmove-"$user".tar.gz
done
#Tar Apache config. Upload to BQbackup. Delete backup file.
cd /usr/local/apache
tar cf /home/apache-conf.tar.gz conf
scp /home/apache-conf.tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f /home/apache-conf.tar.gz
#Tar shared applications. Upload to BQbackup. Delete backup file.
cd /usr/local/share
tar cf /home/shared-htdocs.tar.gz htdocs
scp /home/shared-htdocs.tar.gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/
rm -f /home/shared-htdocs.tar.gz
#Change to SQL backup folder. Upload files to BQbackup.
cd /home/sqlbu/export
scp *gz <bqbackupusername>@<bqbackupusername>.bqbackup.com:week1/sqlbu/
)
Since there is access to root WHM, why not use the built-in backup facility in WHM to do account backups? And then ftp or rsync the files to a remote ftp / backup server?
#!/bin/sh
( ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com rm -rf week4;mv week3 week4;mv week2 week3;mv week1 week2;mkdir week1;mkdir week1/sqlbu
cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' |
while read user; do
/scripts/pkgacct "$user"
scp /home/cpmove-"$user".tar.gz <bqbackupuser>@<bqbackupuser>.bqbackup.com:week1/
rm -f /home/cpmove-"$user".tar.gz
done
)
OMG that is SO sweet! All you need to run the backups is thisFour weeks of backups kept and rotated. All users backed up using Cpanels backup script so full restores can be done.Code:#!/bin/sh ( ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com rm -rf week4;mv week3 week4;mv week2 week3;mv week1 week2;mkdir week1;mkdir week1/sqlbu cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' | while read user; do /scripts/pkgacct "$user" scp /home/cpmove-"$user".tar.gz <bqbackupuser>@<bqbackupuser>.bqbackup.com:week1/ rm -f /home/cpmove-"$user".tar.gz done )
NICE
Thanks Khiltd for the help and Josh for asking the questions!
( ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com rm -rf week4
ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com mv week3 week4
ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com mv week2 week3
ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com mv week1 week2
ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com mkdir week1
ssh <bqbackupuser>@<bqbackupuser>.bqbackup.com mkdir week1/sqlbu
cat /etc/passwd | awk -F':' '/\/home/ { print $1 }' |
while read user; do
/scripts/pkgacct "$user"
scp /home/cpmove-"$user".tar.gz <bqbackupuser>@<bqbackupuser>.bqbackup.com:week1/
rm -f /home/cpmove-"$user".tar.gz
done
)
The base backup utility is fairly limited on backup rotation and historically when I used it it was very cpu intensive. Granted I do not know how it is now but I am able to rotate my backups on a schedule I know and I can also backup more than just accounts this way.