Backing up a Remote Computer on Linux

Some time ago I created a backup script for backing up a database server. I created it in PHP unfortunately, but works the way I like - so with that said I come to share it here.

It uses the Push method of backing up the data - where the source computer pushes the data to the destination computer. In other words you run this script on the source computer and NOT the destination computer. It also assumes you have PHP installed - that doesn’t mean you have to have a web server installed… just PHP. Additionally you’ll need nmap (or some type of pinger program) and rar or zip (compression) program.

At the top of the program change the settings to what you’d like:

Settings for destination computer to determine if the host is alive.
# CONFIGURATION
$settings['host'] = "10.10.10.5";
$settings['port'] = "139";

Compression Settings used with RAR.
# COMPRESSION SETTINGS
$settings['csize'] = "650"; # size of archives in MB
$settings['clevel'] = "0"; # compression level (0-store...3-default...5-maximal)

Program Paths - change to what fits your needs
# PROGRAM PATHS
$app['rar'] = "/usr/local/bin/rar a -ag[MM-DD-YYYY] -s -v".$settings['csize']."m -rr3p -r -m".$settings['clevel']." ";
$app['nice'] = "/bin/nice";
$app['nmap'] = "/usr/bin/nmap";
$app['rm'] = "/bin/rm -f";

File paths are the paths of your source and destination as well as any prefixes/wildcard settings you wish to setup.
# FILE PATHS
$path['src'] = "/home/mysql_db/"; # with trailing slash
$path['dst'] = "/mnt/raid5/_Web-backup/"; # with trailing slash
$path['srcprefix'] = "mysql-";
$path['dstprefix'] = "*";
$path['rmprefix'] = $path['srcprefix']."*.rar";

Download the whole program here - make sure you remove the suffix of .txt.

References:
RAR for Linux
Nmap for Linux
PHP


About this entry