English (United Kingdom)
Jms Multi Site, formerly joomla multisite.
Create, share multiple joomla sites in few clicks !
Home Documentation Weekly Backup Script
Message
  • EU e-Privacy Directive

    This website uses cookies to manage authentication, navigation, and other functions. By using our website, you agree that we can place these types of cookies on your device.

    View e-Privacy Directive Documents

Details for Weekly Backup Script
PropertyValue
NameWeekly Backup Script
Description

Concept

The "weekly backup script" is a shell script that can be used in a cron of you hosting environment in aim to perform the backup of a DB and the backup of a directory on the disk.

This script save the backup in a subdirectory "weekly" followed by a subdirectory with the name of the day.
So that you have maximum 7 subdirectories (one for each day of the week).

Installation

  • Download the "backup_weekly.sh"
  • Transfert the "backup_weekly.sh" script by FTP or other tool on your server.
    We suggest that you create a "backup" directory on your server and that you put the script in this directory.

    The result of the backup will be stored in directory like
    backup/weekly/Monday/BackupName.tgz
    backup/weekly/Tuesday/BackupName.tgz
    backup/weekly/Wednesday/BackupName.tgz
    backup/weekly/Thirsday/BackupName.tgz
    backup/weekly/Friday/BackupName.tgz
    backup/weekly/Saturday/BackupName.tgz
    backup/weekly/Sunday/BackupName.tgz
  • With a chmod, change the permission of the file to add the "execute" attribute

Syntax

The backup shell script contain several parameters:

Mandatory parameters

  • $1 = backup name.
    This will create a subdirectory with this name in the weekly/Day/[backup name]

  • $2 = Joomla PHP Code directory to backup

  • $3 = DB name
  • $4 = DB user
  • $5 = DB password
Optional parameters used when the backup must also be sent by FTP on another (remote) server in case of a crash of your server.
  • $6 = FTP URL
  • $7 = FTP User
  • $8 = FTP Psw
  • $9 = FTP remote directory where to save the file.
    A weekly subdirectory with the day name is automatically created in the remote directory specified.

The parameters are divided in 2 categories.
The first parameters allows specifying the DB parameters and the directory that must be backup.

Sample syntax

The following syntax assume that you are in the directory where you have copied the "backup_weekly.sh" and that you are logged on your server with SSH.

  • backup_weekly.sh test /home/CPANEL_ACCOUNT/domains/jms2win.com/subdomains/master/public_html dbname dbuser "DB-Password" ftp.yourdomain.com ftpuser ftppassword /backup/

    This execute a backup that will be named "test" and for which the result is send by FTP into an FTP root  directory '/backup/'
    The result will be stored in "/backup/weekly/DAY/test.tgz"
  • backup_weekly.sh test /home/CPANEL_ACCOUNT/domains/jms2win.com/subdomains/master/public_html dbname dbuser "DB-Password" ftp.yourdomain.com ftpuser ftppassword

    Same as the previous case but the FTP Root directory is empty. So it is assume that it is sent in the home directory of the FTP account.
    The result will be stored in "/weekly/DAY/test.tgz"
  • backup_weekly.sh test /home/CPANEL_ACCOUNT/domains/jms2win.com/subdomains/master/public_html dbname dbuser "DB-Password"

    Backup without FTP transfert.
    The backup remain in the local directory as follow  "weekly/DAY/test.tgz"

Limitations

  • It is assumed that the DB is located in the "localhost".
    If you want to perform backup from DB that are located on another server, you will have to modify the "mysqldump"
  • The DB backup is performed with NO table locking and also ignore the SQL error that would stop the script.
    If you want to perform a backup with "table locked", remove the "--lock-tables=false" command in the mysqldump
  • We recommand to avoid using special characters in the FTP password.
    If you have special character, perhaps you should change the syntax of the LFTP to autorise that.
    We have considered that a specific FTP user and FTP password would be used to transfert the backup on another server.
  • Avoid using a $ (dollar) character in the DB password.
    The $ is generally used in the shell script to identify variable.

remark:

The FTP transfert use a "lftp" command.

If this LFTP is not installed on your server, you can use a "yum install lftp".

In case where you have an error on Perl library dependencies error, see also the following article that may help you.

https://forums.cpanel.net/f34/missing-dependency-lftp-install-242641.html

Filenamebackup_weekly.sh
Filesize1.76 kB
Filetypesh (Mime Type: application/x-shellscript)
Creatoredwin2win
Created On: 01/21/2012 11:37
ViewersEverybody
Maintained byedwin2win
Hits7252 Hits
Last updated on 02/12/2012 09:00
Homepage
CRC Checksum
MD5 Checksum
2Win, Multisite(s) are trademarks of Edwin2Win.
Joomla