Hello guys and ladies,
Long time no see
. Today I’m going to show you how to make a php script to perform full website backup the script can be executed via http request or via ssh shell or like a cron job .
We all know about the most standard way to add backup for your website maintenance for example using the Cron Jobs in the CPanel. If you already don’t know this – if your hosting provider does support CPanel you should be able to access it via this URL: www.yourwebsite.com/cpanel

After you login into you CPanel and choose ‘Cron jobs’ you can enter there manually script to fully backup your database or file system. For example a script for full file system backup should look like this:
tar -cvpzf my_backup_file.tar /home/your_user/public_html
we could make the script more interesting when instead of ‘my_backup_file’ we include the date and time in the filename:
tar -cvpzf `date +%y-%m-%d_%H-%M`.tar /home/ your_user/public_html
of course you should change `/home/your_user/public_html` to whatever your home directory is. You can find out what your home directory is by executing ‘pwd’ (print working directory) in the ssh shell or creating the file `exec.php` with the code:
<?php echo exec(‘pwd’); ?>
and after that executing the code by opening http://www.yoursite.com/exec.php in your browser.
So we can add this line directly into the Curl command field:

But now I am going to tell you better way to do it, because very often the commands directly typed at the cron’s `Command:` field are ignored because of some stupid quote convention etc.
Full website filesystem backup using php file and cron job:
1. First we are going to create the file backup_filesystem.php and put this code into it :
<?php echo exec(‘cd /home/your_user/backup/files;tar -cvpzf `date +%y-%m-%d_%H-%M`.tar /home/ your_user /public_html’); ?>
2. After that we’ll access the website via the FTP and put the backup_filesystem.php file into the /home/your _user/backup/. Make sure that you create “backup” and “backup/files” directories if they are not already created. Better don’t put backup_filesystem.php file into the /public_html/ folder because we don’t want the users to have direct access to the file.
3. Now we are going back to the CPanel -> Cron Jobs. On the common settings we enter Once a day (so the Command will be executed once a day) and on the Command field we enter:
php ‘the path to backup_filesystem.php’

After that click on the ‘Add new cron job’ button and Voila !! – the Cron Job for backup of your database is ready.
The archive is created using low tar compression, so if needed you can archive your site using stronger bzip2 compression by replacing: “tar –cvpzf filename.tar” with “tar –cjf tarname.bz2”.

The full backup of your website is created in the /backup/files directory and can be downloaded via FTP if necessarily – as you see the filename include the date and time of the moment it has been created, so it won’t be hard for you to guess which is the latest version of the backup if needed.
Thank you for your time, next time I’m going to show you how to perform similar backup, but this time full database backup instead of filesystem backup.
Cheers
June 21st, 2010 at 10:32 am
Very straightforward and useful. Thanks.
December 15th, 2011 at 4:55 am
I surely will bookmark your site.Best Regards!caiyifang/comment201112
December 15th, 2011 at 5:29 am
Wow, Great post,Nice work, I would like to read your blog every day Thanks.caiyifang/comment201112
December 15th, 2011 at 5:52 am
This article gives the light in which we can observe the reality This is a really good read for me. its really very good post. Thanks for posting this informative article.caiyifang/comment201112
December 16th, 2011 at 4:15 am
Wow, Great post,Nice work, I would like to read your blog every day Thanks.
December 16th, 2011 at 4:16 am
Nice post.Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks.
December 16th, 2011 at 4:18 am
Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks.
December 17th, 2011 at 2:57 am
Good, I agree with your point of view, thanks for your sharing!I think i am very close to your imagination. caiyifang/comment201112
December 17th, 2011 at 3:59 am
thank you for posting . please do more good article.i like it so much .I will always follow it..caiyifang/comment201112
December 17th, 2011 at 4:29 am
Great post. Thanks for sharing..caiyifang/comment201112
December 17th, 2011 at 11:16 am
http://www.snow-coats.com/ Let us seem at the other outside brand name-Monlcer. It also has its personal thermal
technique. The brilliant hues and abnormal down are used for the duration of the course of
naking to make confident warmth efficiency and comfort.The lousy impression on the
preceding down jackets can be attributed to the incorrect methods to collocate it. If you
December 19th, 2011 at 2:42 am
Mostly all the Websites are for the information purpose and you have also created such a great website here.Such a great ideas you have Provided here.Thank you for sharing
December 19th, 2011 at 2:21 pm
Beige with red highlights, these are for men. There is a woman’s variation Christian Louboutin Volpi 150mm Alba and this is called the Stynger Gtx and it is blue and looks like the slightly christian louboutin sale daintier version of the blue Fugitive. Here are some of the features
December 20th, 2011 at 2:11 am
I love this blog. In fact I challenged myself trying to commence one like this too, but not savvy enough on how to do it. How exactly is this so-called thing? Is it hard? Is it necessary to be smart in computers to create a blog?
December 21st, 2011 at 2:59 am
We are all budding psychologists whether we know it or not and we pick higher a lot from what we suppose others wearing.
December 21st, 2011 at 4:18 am
Good job. I was taught to do things in different blogs more every day. It will all the time to read the content material incentive to other writers and practice some things from their store. I prefer to use some of the content on my blog.
December 21st, 2011 at 7:24 am
moncler pas cher, manteaux moncler
, doudoune moncler
December 21st, 2011 at 7:25 am
Justin Bieber Shoes, Supra TK Society, Supra Vaider
December 21st, 2011 at 9:54 am
今日、MONCLER MAYA Ivoryは、ほとんどの公式の仕入業者、特にMONCLER VBOROSIRI Blueになることを小売業者キューイングによるファッションレーベル引っ張りだこの一つであると主張することができます。そしてこの品物に対しては、提供する様々ながあることがモンクレールを購入することができます。
December 21st, 2011 at 9:55 am
At current you can get a few official Aaron Rodgers Women jersey and even while the gamers use the ordinary uniform in most from the video games, we can see one other two variations at least after or twice a year. In custom nfl Clay Matthews jersey background, it re-wrote the unofficial rule in accordance to which a staff should certainly have on the colored jersey when playing at place.
December 21st, 2011 at 9:56 am
The feature red-sole that makes Christian louboutin outlet shoes stand out at first is the glossy nail-varnish red sole that has become his trademark. Everyone says there is a demand and a desire for society, then the society can progress. And because the christian louboutin platforms in various designs, colors, shapes and styles of construction that have won more than the recovery of millions of women worldwide, it is catch up the demands of times.
December 26th, 2011 at 10:40 am
The main quarterback – Roth Reese Berg because of an ankle injury did not play the game, 37-year-old Charlie – budge first.