Skip to content

Instantly share code, notes, and snippets.

@dennis-f
Created February 27, 2018 10:23
Show Gist options
  • Select an option

  • Save dennis-f/99b06b45766689f330c7c46e53d64ec5 to your computer and use it in GitHub Desktop.

Select an option

Save dennis-f/99b06b45766689f330c7c46e53d64ec5 to your computer and use it in GitHub Desktop.
Tiny script to export most elements (chunks/snippets, tvs, templates etc.) from modx without overwriting any content
#!/bin/bash
# db config
DB_NAME='dbname'
DB_USER='root'
DB_PASS='root'
DB_HOST='localhost'
DB_TABLES='modx_categories modx_categories_closure modx_site_htmlsnippets modx_site_plugins modx_site_snippets modx_site_templates modx_site_tmplvars modx_site_tmplvar_access modx_site_tmplvar_templates'
# date format - used in back-up archive filename
D=$(date +%Y-%m-%d)
# set to exit on error
set -e
# backup the database
mysqldump -u ${DB_USER} -p${DB_PASS} -h ${DB_HOST} ${DB_NAME} ${DB_TABLES} > ${DB_NAME}-${D}-elements.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment