concrete5 backup shell libraries
This is simple shell script to back up your concrete5.7.x & concrete5 Version 8 site. Since you're using GitHub, I assume you know what you're doing. This is the script that runs on your server.
MIT LICENSE and NO GUARANTEE
This script is licensed under The MIT License. USE IT AT YOUR OWN RISK.
You need to have the server that allows to run the shell script.
- Add your server config in
- If you don't uncomment MYSQL_PASSWORD option, you will have to enter MySQL Password every time you run this script.
- Upload the
concrete5-backup.shto your server
- Change the file permission
chmod 700 concrete5-backup.shOr whatever the permission you need to execute the file. But make sure to minimize the permission.
- 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 concrete5 folder.
This script first save the SQL dump file onto concrete5 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.
cd path/to/shell/file sh concrete5-backup.sh [1st option] [2nd option]
cd /var/www/html sh concrete5-backup.sh --all --relative
1st option will determine how much file you want to backup
FILES option (default)
back up a SQL and the files in application/files, application/config/generated_overrides, application/config/doctrine and application/language files.
- [no option]
Database + CONFIG option
back up a SQL and the files in application/config/generated_overrides, application/config/doctrine and application/language files.
- [no option]
back up only a SQL dump file under WHERE_IS_CONCRETE5 path
ALL file option
back up a SQL and all files under WHERE_IS_CONCRETE5 path
back up a SQL, and the files in application/ (all files), packages/
CONCRETE5 MINIMUM option
back up a SQL, and application (EXCEPT files), concrete, packages, updates folders and composer.*, index.php, robots.txt files. This is useful option if you want to backup all concrete5 files BUT excluding inside of file managers.
This is useful option that you want to backup concrete5 files, but not the file manager files. It won't backup any other non-concrete5 files on the concrete5 document root directory such as sitemap.xml, site verification files.
ALL CONCRETE5 option
back up a SQL, and application, concrete, packages, updates folders and composer.*, index.php, robots.txt files.
This is useful option if the concrete5 root directory contains many non-concrete5 folders. It won't backup any other non-concrete5 files on the concrete5 document root directory such as sitemap.xml, site verification files.
Shows all the help options.
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.
The shell always use absolute path when dumping and zipping files.
VARIABLES TO SET
Once you download the sh file, you must change the where VARIABLES is from line 15
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
Enter the server full path where you want to save your backup files to.
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.
Enter the full server path of where your concrete5 site is installed
Enter the identical file name. This will be the prefix of your file.
Enter the MySQL server address.
Enter the name of your MySQL database.
Enter the MySQL username
If you don't want to enter the password every time, uncomment the MYSQL_PASSWORD and enter the MySQL password.
You must set what character default-character encoding when exporting the dump.
utf8mb4is recommended if you want emoji support.
utf8is recommended if you are still using older server without emoji support.
MYSQL_IF_NO_TABLESPACE (true or false)
If you are using MySQL 5.7.31 or later, and you encounter the following error, you must set it to
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
If you are using earlier version of MySQL or MariaDB, please set it
This is the shell script and concrete5 job which copies the production concrete5 to develop environment and modify user (mainly to make users info anonymous, or delete).
Read inside of each script and modify the necessary parameters.
concrete5 jobs are set NOT TO RUN under
default environments make sure to adjust if it doesn't run.
3.2.0 (June 2, 2021)
MYSQL_CHARASETconfig parameter to be able to set your default character encoding of mysqldump
MYSQL_IF_NO_TABLESPACEconfig to make the shell configurable
- Better Readme documentation
3.1.2 (May 24, 2021)
--no-tablespacesparameter to mysqldump commands, so that it can prevent the error
Access denied; you need (at least one of) the PROCESS privilege(s) for this operationsince MySQL 5.7.31.
3.1.1 (May 21, 2021)
--default-character-set=utf8parameter from mysqldump command so that if post 8.5.0 ConcreteCMS has utf8mb4 DB, it will respect the DB setting.
- TBD: whether to add default character option or not.
3.1.0 (March 22, 2021)
- config option added to save generated_overrides, proxies and language files. Default file option also now saves those config files.
3.0.0 (March 16, 2020)
concrete5-copy.shto copy production c5 to develop c5 if the both environment lives within a same server.
2.2.0 (Februrary 20, 2020)
- Added CONCRETE5 MINIMUM and ALL CONCRETE5 options
2.1.1 (October 24, 2018)
- Fixed a bug which --all option stopped in the middle and leaving the tar & sql file in WHERE_IS_CONCRETE5 Path.
- Better documentation
2.1 (June 28, 2018)
Changed compress option from zip to tar because tar is better to contain file ownership and group information.
2.0L (April 3, 2016)
Made the legacy version to support concrete5.6.x and before. Switch the branch to legacy.
2.0 (December 28, 2015)
--single-transactionoption 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.
Please feel free to create an issue or send me a pull request. Your feedback is always welcome!