#!/bin/bash
#
######################################################
#
# File: backup.sh
#
# Description: Creates a backup of all important data with GNU tar
# Compatibility: Works with vSERVER running SuSE 9.0
#
######################################################
# directories to be backed up
#
BACKUP_DIRS="/etc /root /home /usr/local/confixx /usr/local/bin /usr/local/sbin /srv /var/log /var/lib/mysql"
# check if all directories are valid
#
for DIR in $BACKUP_DIRS; do
if [ ! -d $DIR ]; then
echo "$DIR is not a valid directory."
exit 1
fi
done
# location of required binaries
#
tar=/bin/tar
if [ ! -x ${tar} ]; then
echo " ERROR: could not find tar binary. Exiting..."
exit 1
fi
du=/usr/bin/du
if [ ! -x ${du} ]; then
echo " ERROR: could not find du binary. Exiting..."
exit 1
fi
awk=/usr/bin/awk
if [ ! -x ${awk} ]; then
echo " ERROR: could not find awk binary. Exiting..."
exit 1
fi
date=/bin/date
if [ ! -x ${date} ]; then
echo " ERROR: could not find date binary. Exiting..."
exit 1
fi
hostname=/bin/hostname
if [ ! -x ${hostname} ]; then
echo " ERROR: could not find hostname binary. Exiting..."
exit 1
fi
# timestamp of the file
#
TIMESTAMP=`${date} +"%Y%m%d"`
# name of the backup file
#
BACKUP_FILE=/backup/backup-$TIMESTAMP.tar.gz
# show some fancy user information output
#
echo ""
echo " vSERVER backup (`${date}`)"
echo " ============================================================="
# check whether the backup file exists; if so, we exit
# because we don't want to overwrite the file
#
if [ -f $BACKUP_FILE ]; then
echo " ERROR: Backup file $BACKUP_FILE exists."
echo " Please remove it manually before running the backup."
exit 1
fi
echo -n " Creating backup of vSERVER `${hostname}`: "
# create the backup
#
${tar} czf $BACKUP_FILE $BACKUP_DIRS &>/dev/null
ERRCODE=$?
# print backup success or failure
#
if [ $ERRCODE -eq 0 ]; then
BACKUP_FILE_SIZE=`${du} -sh $BACKUP_FILE | ${awk} '{ print $1 }'`
echo "DONE"
echo " Filename: $BACKUP_FILE ($BACKUP_FILE_SIZE)"
echo ""
exit 0
else
echo "FAILED"
echo ""
exit 1
fi
<?php
error_reporting(E_ALL);
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "PASSWORD";
$dbnames[0] = "usr_web1_1";
$dbnames[1] = "usr_web1_2";
$datum = date("d-m-Y");
$datsql = date("m-d-Y");
$pfad = "/backup/";
$pfadmysql = "/backup/mysql/";
foreach($dbnames as $dbname)
{
$datei = $dbname . "-" . $datsql . ".sql.gz";
system(sprintf('mysqldump -q -a -c -e -h %s -u %s -p%s %s | gzip > %s/%s',
$dbhost, $dbuser, $dbpass, $dbname, $pfadmysql, $datei), $return);
}
system("rm " . $pfad . "mysql-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "mysql-backup.tgz /var/lib/mysql/", $outputtmp);
system("rm " . $pfad . "web-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "web-backup.tgz /srv/", $outputtmp);
system("rm " . $pfad . "irc-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "irc-backup.tgz /home/irc/", $outputtmp);
system("rm " . $pfad . "root-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "root-backup.tgz /root/", $outputtmp);
system("rm " . $pfad . "etc-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "etc-backup.tgz /etc/", $outputtmp);
system("rm " . $pfad . "confixx-backup.tgz");
exec("tar -c -z -v -f " . $pfad . "confixx-backup.tgz /usr/local/confixx", $outputtmp);
?>
We use cookies and similar technologies to provide the best experience on our website. You can choose which purposes you consent to. Your choice applies across websites using the same consent framework.
Below you can select which purposes you consent to. Purpose 1 is required for basic website functionality.
Cookies, device or similar online identifiers together with other information can be stored or read on your device for the purposes presented to you.
Ads can be shown to you based on the content you are viewing, the app you are using, your approximate location, or your device type.
A profile can be built about you and your interests to show you personalised ads that are relevant to you.
Personalised ads can be shown to you based on a profile about you.
A profile can be built about you and your interests to show you personalised content that is relevant to you.
Personalised content can be shown to you based on a profile about you.
The performance and effectiveness of ads that you see or interact with can be measured.
The performance and effectiveness of content that you see or interact with can be measured.
Market research can be used to learn more about the audiences who visit sites/apps and view ads.
Your data can be used to improve existing systems and software, and to develop new products.
Content can be selected based on limited data, such as the content you are viewing or the device you are using.
Below is a list of all technology vendors that may process your data. You can enable or disable each vendor individually.