Just made shell script to backup your Concrete CMS easily (Server knowledge required)

This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
Jan 13, 2016

This is simple shell script to back up your Concrete CMS 5.7.x site.

You must have certain knowledge of using server via SSH and/or terminal.

MIT LICENSE and NO GUARANTEE

This script is licensed under The MIT License. USE IT AT YOUR OWN RISK.

DISCLAIMER:There may be updated version. Please visit GitHub to check the latest version.

Where to download

https://github.com/katzueno/concrete5-backup-shell

And download and saveconcrete5-backup.sh.

Set-up

You need to have the server that allows to run the shell script.

  1. Add your server config in concrete5-backup.sh
  2. If you don't uncomment MYSQL_PASSWORD option, you will have to enter MySQL Password every time you run this script.
  3. Upload the concrete5-backup.sh to your server
  4. Change the file permission chmod 700 concrete5-backup.sh Or whatever the permission you need to execute the file. But make sure to minimize the permission.
  5. Run the sh file from ssh or set-up CRON job.

It's is highly advised that you know what you're doing with this script. You MUST have certain amount of knowledge of what shell script is.

CAUTION: Check your concrete folder.

This script first save the SQL dump file onto concrete directory. If the script fails, it may leave the SQL file under the server. MAKE SURE to check the server occasionally.

How to Run and Options

At default, you still need to enter the MySQL Password.

Format

cd path/to/shell/file

sh concrete5-backup.sh [1st option] [2nd option]

Example

cd /var/www/html

sh concrete5-backup.sh --all --relative

1st Option

1st option will determine how much file you want to backup

FILES option (default)

back up a SQL and the files in application/files

  • [no option]
  • --files
  • --file
  • -f

DATABASE option

back up only a SQL dump fule under WHERE_IS_CONCRETE5 path

  • --database
  • -d

ALL file option

back up a SQL and all files under WHERE_IS_CONCRETE5 path - --all - -a

PACKAGE option

back up a SQL, and the files in application/files, packages/

  • --packages
  • --package
  • -p

HELP option

Shows all the help options.

  • --help
  • -h

2nd option

You MUST specify 1st option if you want to specify 2nd option.

2nd option determine if you need to work as absolute path or relative path. A Mac OS User reported that they need to be specify absolute path. You may need to use the 2nd option if you're running this as a cron job.

RELATIVE option (default)

The shell runs relative path.

  • [default]
  • -r
  • --relative

ABSOLUTE option

The shell always use absolute path when dumping and zipping files.

  • -a
  • --absolute

VARIABLES TO SET

Once you download the sh file, you must change the where VARIABLES is from line 15

NOW_TIME

Default:date "+%Y%m%d%H%M%S"

It would add current year, month, date, hour, and seconds to the backup files.

For example, if you think you don't want to put all the minutes and second, remove %M%S.

WHERE_TO_SAVE

Enter the server full path where you want to save your backup files to.

e.g. WHERE_TO_SAVE="/var/www/html/backup"

HINT: If you don't know where to find, use "pwd" command to find your current location of the server to find the full path of the server.

WHERE_IS_CONCRETE5

Enter the full server path of where your concrete5 site is installed

e.g. WHERE_IS_CONCRETE5="/var/www/html/concrete5"

FILE_NAME

Enter the identical file name. This will be the prefix of your file.

e.g. FILE_NAME="katzueno"

MYSQL_SERVER

Enter the MySQL server address.

e.g. MYSQL_SERVER="localhost"

MYSQL_NAME

Enter the name of your MySQL database.

e.g. MYSQL_NAME="database"

MYSQL_USER

Enter the MySQL username

e.g. MYSQL_USER="root"

MYSQL_PASSWORD (Option)

If you don't want to enter the password every time, uncomment the MYSQL_PASSWORD and enter the MySQL password.

e.g. MYSQL_PASSWORD="root"

Future Plan

  • Support of TAR
    • (Actually, you could uncomment line 155 and 163 and comment-out line 156 and 164)

Version History

DISCLAIMER:There may be updated version. Please visit GitHub to check the latest version.

2.0 (December 28, 2015)

  • --single-transaction option added to MySQLdump command (thanks Endo-san)
  • 2nd option of relative path or absolute path added for Mac OS user (thanks Endo-san)
  • database option added: option to only back-up the SQL dump file
  • Some script validation using www.shellcheck.net
  • Fix some English

1.0.1 (December 26, 2015)

  • Fix where the ALL option generates error because it was indicating the same zip location twice.

1.0 (December 26, 2015)

  • First version.

Contact

http://katzueno.com/

Please feel free to create an issue or send me a pull request. Your feedback is always welcome!

Where to download

https://github.com/katzueno/concrete5-backup-shell

Recent Tutorials
Customize locale icons
Oct 29, 2024
By myq.

How to customize locale (language region) flags

Concrete CMS Caching Guide
Oct 16, 2024

An overview of types of caching in Concrete and considerations when using them.

Redirect all requests to HTTPS
Oct 9, 2024
By myq.

How to follow best practices for a secure web

Upgrade Concrete versions 9.3.1 and 9.3.2
Sep 10, 2024
By myq.

How to get past a bug in versions 9.3.1 and 9.3.2 that prevents upgrading the Concrete core through the Dashboard

How to use Composer with Marketplace extensions
Aug 22, 2024

Composer can be used to manage third-party extensions from the marketplace

Controlling Google Tag Manager Tags Based on Concrete CMS Edit Toolbar Visibility
Aug 13, 2024

This document provides a step-by-step guide on how to control the firing of Google Tag Manager (GTM) tags based on the visibility of the Concrete CMS edit toolbar. It explains how to create a custom JavaScript variable in GTM to detect whether the edit toolbar is present on a page and how to set up a trigger that ensures GTM tags only fire when the toolbar is not visible. This setup is particularly useful for developers and marketers who want to ensure that tracking and analytics tags are not activated during content editing sessions, thereby preserving the accuracy of data collected.

Improvements?

Let us know by posting here.