Skip to content

Instantly share code, notes, and snippets.

@billmn
Created February 18, 2022 08:45
Show Gist options
  • Save billmn/9e4c8cf6354c7436b666314cb006ef32 to your computer and use it in GitHub Desktop.
Save billmn/9e4c8cf6354c7436b666314cb006ef32 to your computer and use it in GitHub Desktop.
Craft CMS: DB Backup command using Homebrew
# Backup/Restore commands
BACKUP_COMMAND="/opt/homebrew/bin/mysqldump -h localhost -u root -p --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --single-transaction --no-data --result-file=\"{file}\" {database} && /opt/homebrew/bin/mysqldump -h localhost -u root -p --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --no-create-info --ignore-table={database}.assetindexdata --ignore-table={database}.assettransformindex --ignore-table={database}.cache --ignore-table={database}.sessions --ignore-table={database}.templatecaches --ignore-table={database}.templatecachecriteria --ignore-table={database}.templatecacheelements --ignore-table={database}.templatecachequeries {database} >> \"{file}\""
RESTORE_COMMAND="/opt/homebrew/bin/mysql -h localhost -u root -p {database} < \"{file}\""
<?php
return [
// ...
'backupCommand' => App::env('BACKUP_COMMAND'),
'restoreCommand' => App::env('RESTORE_COMMAND'),
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment