https://dev.webpages.dk/  
 
PHP How to make automated backup
How to make automated backup:

To the right of here you can see some examples on how to make backup using cron and PAX. Scroll down and you can see how a cron string can be created.

Use cron for making automated backup on both your server and your personal computer.

Be sure to read the dedicated page about Cron.

 How to make automated backup

How to use PAX for making automated backup

If you found the last posting interesting, then I am sure you will like this one also.
We made a script that makes use of PAX, a commandline tool, for making backup of our projects.

Now we will make cronjobs for executing those scripts, so that we totally automize the backup procedures on our machine.

Lets recall our script..

cd /home/you/lampstack/apache2/htdocs/project
rm backup.pax
pax -wzf backup.pax .
cp backup.pax /home/you/backup/project/$(date +%F).pax
About crontab: cron is the system process which will automatically perform tasks for you according to a set schedule. The schedule is called the crontab, which is also the name of the program used to edit that schedule. (Cite from the website linked to at the end of this text). Here is how the crontab entry looks if we want to execute our script every hour at 15 minutes past the hour.

15 *  * * * /home/you/programs/scripts/cronjob_15.sh

Here we execute the same cronjob every workday of the week at 15 minutes past 8 (AM).

15 8  * * 1-5 /home/you/programs/scripts/cronjob_15.sh

A cronjob consist of 6 entries.

The first is Minutes (0-59)
The second is for hours (0-23)
Third is day of month (1-31)
Fourth entry is month (1-12)
Fifth is day of week (0-7)
Sixth is the path to the scriptfile to run.

Notice that in the fifth both 0 an 7 are Sundays.

10  8  *  *  1-5  path/to/script
 |__|__|__|___|___|__________________ Minuts
    |__|__|___|___|__________________ Hours
       |__|___|___|__________________ Day in month
          |___|___|__________________ Month
              |___|__________________ Weekday
                  |__________________ Script to execute

Okay. So we have the information we need to build our automated backup scripts. I assume that we use the script as seen above. And that we use the second example of the cronjob also above here. Now we need to enter the job into the crontab. We can do that easliy. Write in the following in your terminal:

$ crontab -e

.. this will open the nano editor with the crontab config file.
I made two screenshots of the nano editor, you see those here:



As you can see, the bottomline in the third shot show our entry into the crontab.

When you have written the line into nano end by hitting CTRL-X. The nano editor will ask you if you want to save. Hit Y (yes), and then A (append).
Your cronjob should have been added now. You can check it by typing this:

cronjob -l

Remember to look at:

man crontab

Now your system will create a backup every workday at 15 minutes pass 8 o'clock.


 HTML

<HTML><BODY> 


</BODY></HTML>

 PHP

<?php


?>
Icons made by Freepik from www.flaticon.com Make a backup script with PAX, and run it as a CronJob.
07:40:14