Backup Sites and DBs

Released 4 years ago , Last update 4 years ago

A maintenance script that will dump all your sites and databases every day into a backup folder.

Not all hosting services provide scheduled backup features, so this small tool is perfect to protect your sites in that case. Place it on hosting and change default settings on your one

define('DUMPS_PATH', 'PATH TO DUMP FOLDER');
define('ROOT_PATH',   'PATH TO ROOT SITES FOLDER');
$folders = array(
        'SITE FOLDER 1',
        'SITE FOLDER 2'
);
define('DB_HOST', 'HOSTING DB HOST');
define('DB_USER', 'HOSTING DB USER');
define('DB_PASS', 'HOSTING DB PASSWORD');

And you will get script that will perform the following actions daily:

  • Exports all DBs (allowed for DB_USER, so you can create special db-user and share all dbs with him)
  • Exports all CHANGED folders in the $folders list from ROOT_PATH
  • Gzips all data and save it in DUMPS_PATH
3.9
  • 5 4
  • 4 1
  • 3 0
  • 2 1
  • 1 1
7 Reviews Read Reviews

Pricing

FREE

Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

Need custom services for this product? Get a quote
License » Personal License Download

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

or Get a quote

for customization or integration services


Or enter your name and Email
  • M Momin 6 months ago
    is it possible to backup particular database and its respective subdomain? plz reply... i m working on that module so? Plz
    • Ksu Zhytomirsky Publisher 6 months ago
      define('ROOT_PATH', '/data2/deploy/'); $folders = array( 'my_only_folder' ); this is one folder setting... for one database - change db listing to only one db /* $result = mysql_list_dbs($conn); $dbs = array(); while($row = mysql_fetch_row( $result )) { if ($row[0] == 'information_schema') continue; $dbs[] = $row[0]; } */ $dbs = array('my only database name');
    • Ksu Zhytomirsky Publisher 6 months ago
      <?php define('DUMPS_PATH', 'PATH TO DUMP FOLDER'); define('ONE_SITE_PATH', 'FULL PATH TO ROOT SITE FOLDER'); define('DB_HOST', 'HOSTING DB HOST'); define('DB_USER', 'HOSTING DB USER'); define('DB_PASS', 'HOSTING DB PASSWORD'); define('ONE_DB_NAME', 'HOSTING DB NAME'); $big_dump_file = DUMPS_PATH . date('Y-m-d') . '.all.tgz'; $dump = DUMPS_PATH . date('Y-m-d') . '/'; if (!file_exists($big_dump_file)) { if (!is_dir($dump)) { mkdir($dump); } $db_file = $dump . ONE_DB_NAME . '.sql'; if (!file_exists($db_file) || (time() - filemtime($db_file) > 6000)) { $command = 'mysqldump -u ' . DB_USER . ' -p' . DB_PASS . ' ' . ONE_DB_NAME . ' > ' . $db_file; echo 'mysqldump ' . ONE_DB_NAME . '<br/>'; exec($command); } $dump_file = $dump . '.site.tgz'; $tmp_file = $dump . '.site.tmp'; if (!file_exists($tmp_file) || (time() - filemtime($tmp_file) > 6000)) { unlink($tmp_file); $command = ' find ' . ONE_SITE_PATH . ' -mtime -1 >> ' . $tmp_file; echo 'find ' . ONE_SITE_PATH . '<br/>'; exec($command); $modified = file_get_contents($tmp_file); if ($modified) { if ( strpos($modified, '.php') || strpos($modified, '.ctp') || strpos($modified, '.html') || strpos($modified, '.css') || strpos($modified, '.js') || strpos($modified, '.jpeg') || strpos($modified, '.jpg') || strpos($modified, '.gif') | strpos($modified, '.png') ) { $command = 'tar -cvzpf ' . $dump_file . ' ' . ONE_SITE_PATH; echo 'tar ' . $folder . '<br/>'; exec($command); } } } $command = 'tar -cvzpf ' . $big_dump_file . ' ' . $dump; echo 'gzip all<br/>'; exec($command); foreach ($folders AS $folder) { $tmp_file = $dump . $folder . '.tmp'; unlink($tmp_file); } } //this remove old dumps $date = date('Y-m-d', strtotime('-2 days')); $prev_dump_file = DUMPS_PATH . $date . '.all.tgz'; $prev_dump = DUMPS_PATH . $date . '/'; if (file_exists($prev_dump)) { $d = dir($prev_dump); while($entry = $d->read()) { if ($entry!= "." && $entry!= "..") { unlink($prev_dump . $entry); } } $d->close(); rmdir($prev_dump); } if (file_exists($prev_dump_file)) { unlink($prev_dump_file); } echo 'OK!';
    • M Momin 6 months ago
      thanking you..hope the problem will solve... :)
  • M Momin 6 months ago
    can you provide a basic example for customizing code mentioned above with some dummy url or path....? I am little bit confused so..