Jump to content
  • Welcome To Mopar1973Man.Com

    We can see you lurking about Mopar1973Man.Com reading articles and reading other member's posts. Are you trying to solve a problem with your Dodge / Ram Turbo Diesel Cummins? We have lots of helpful members and staff on the Mopar1973Man.Com and are willing to give guidance on how to fix or improve your truck. You know when you see good valued information here on Mopar1973Man.Com. We are not corporate owned like many of the other websites out there. Like Cummins Forum (VerticalScope Inc.). Mopar1973Man.Com is entirely privately owned and operated since 2004. Your subscription funds goes towards server maintenance and software maintenance. We happen to be one of the most friendliest and helpful websites for Cummins Owners in the world. Come join us and register and then pick a subscription plan


Backing up your web server to Home PC

Recommended Posts

  • Administrator

Here is a page from nixCraft that is super simple and covers everything for you. Compressing the files, making one compressed file to send, even backs up your MySQL data too. 




The only twist I love to do this is set the shell script in a root folder and root permissions. Now setup Anacron to run that shell script every day or every week. The system will not ask for passwords or prompt you if the script is correct. It should run quietly in the background doing it job once a day or once a week.


Cron vs. Anacron. Cron will require the machine to be on at the set time every day it suppose to run. If the time is missed the script does not run period.  Anacron if you miss the run time it will still run the shell script if missed then flags that the script has ran for this period and waits for the next period. Not time or date sensitive.


# A Simple Shell Script to Backup Red Hat / CentOS / Fedora / Debian / Ubuntu Apache Webserver and SQL Database
# Path to backup directories
DIRS="/home/vivek/ /var/www/html/ /etc"
# Store todays date
NOW=$(date +"%F")
# Store backup path
# Backup file name hostname.time.tar.gz 
BFILE="$(hostname).$(date +'%T').tar.gz"
PFILE="$(hostname).$(date +'%T').pg.sql.gz"
MFILE="$(hostname).$(date +'%T').mysql.sq.gz"
# Set Pgsql username
# Set MySQL username and password
# Remote SSH server setup
SSHSERVER="backup.example.com" # your remote ssh server
SSHUSER="vivek"                # username   
SSHDUMPDIR="/backup/remote"    # remote ssh server directory to store dumps
# Paths for binary files
# make sure backup directory exists
[ ! -d $BACKUP ] && mkdir -p ${BACKUP} 
# Log backup start time in /var/log/messages
$LOGGER "$0: *** Backup started @ $(date) ***"
# Backup websever dirs
$TAR -zcvf ${BACKUP}/${BFILE} "${DIRS}"
# Backup PgSQL
# Backup MySQL
$MYSQLDUMP  -u ${MYSQLUSER} -h localhost -p${MYSQLPASSWORD} --all-databases | $GZIP -9 > ${BACKUP}/${MFILE}
# Dump all local files to failsafe remote UNIX ssh server / home server
# Log backup end time in /var/log/messages
$LOGGER "$0: *** Backup Ended @ $(date) ***"


Edited by Mopar1973Man
Link to post
Share on other sites

  • Create New...