Avatar of crazywolf2010
crazywolf2010
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Website Backup Script

Hi,
I need a website backup script under linux.

I am looking for functionality like
1. Carrying FULL backup every weekend
2. Backing daily for changed files
3. Keeping Full Backup set for 4 weeks
4. I should  able to exclude certain directories in backup set
5. Backup mySQL databases
6. Email success/failure in backup execution
7. Copy backup files to remote location


Thanks
LinuxShell ScriptingUnix OS

Avatar of undefined
Last Comment
madunix

8/22/2022 - Mon
psrsathish

Hi,

Rsnapshot will fulfill all your needs. I am using this free opensource tool for more than a years to backup  the website/database/mail or even the whole drive. You can backup the files to remote location too.

It will fulfill all your seven points.

http://www.howtoforge.com/installing-rsnapshot-on-centos
http://rsnapshot.org/howto/1.2/rsnapshot-HOWTO.en.html

Cheers!
crazywolf2010

ASKER
Hi,
I am using hosted environment and don't have complete access to install rsnapshot. I really need a shell script solution.

Thanks
Gerwin Jansen

Are you allowed to run scheduled jobs (cron) on your hosted environment?

What does your hosting provider offer for backup possibilities? They usually perform backups, is this a cost related issue maybe?
Your help has saved me hundreds of hours of internet surfing.
fblack61
arober11

Is rsync or any of its derivatives available?
psrsathish

Hi,

Did your hosting provider offer any control panel to you to manage the hosted domains?
If yes then do you have a Backup option in your control panel?
crazywolf2010

ASKER
Hi,
I can run scheduled jobs and have ssh access.
I do not have root access to load anything new. rsync else dirvish is not on the box.

Thanks
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
psrsathish

Did your hosting provider offer any control panel to you to manage the hosted domains?
If yes then do you have a Backup option in your control panel?
Gerwin Jansen

When looking at your requirements:
1. Carrying FULL backup every weekend
- Use FTP (WinSCP for example) to get all backups after scheduled jobs ran

2. Backing daily for changed files
- Why would you want this? Is your site that large that you don't have enough space available?

3. Keeping Full Backup set for 4 weeks
- schedule #1 -> create a tar.gz file of your whole site, excluding certain directories, create 4 schedule instances in cron, 1 for each week so you have 4 backup files available at all times

4. I should  able to exclude certain directories in backup set
- Use a tar command that includes the directories you want (the other way around)

5. Backup mySQL databases
- Use the standard "mysqldump -h localhost -u username -p database_name > backup_db.sql" command to create your backup

6. Email success/failure in backup execution
- After each scheduled job, check status ($?) and call a mail routine.

7. Copy backup files to remote location
- How do you want to do this? In case you want to FTP, you can create a .netrc file in the homedir of your user account and schedule an FTP job at your required intervals. Easier imho is to get your files using FTP (WinSCP).
crazywolf2010

ASKER
Hi,
I don't have intention to reinvent the wheel.

Have you seen scripts like these ones
http://lassebunk.dk/2011/03/11/linux-backup-script/
http://codebox.org.uk/pages/scripts/backup

I need something like this ...


Thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Gerwin Jansen

No, I haven't, would you care to comment on the hosting questions above? Do you maybe have some sort of script already?
crazywolf2010

ASKER
Hi,
I do have cpanel access I think .  
I don't want to carry the backup manually. Also I don't see any mysql backup option there. I may able to do the file backup which is not enough.
I had a backup script earlier but during ISP moving I missed to copy it .I can't remember the one I used.

Thanks
Gerwin Jansen

Here's another one: http://davehope.co.uk/Blog/backup-your-linux-vps-to-dropbox/

Just give it a try, good luck!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
madunix

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question