|
16 | 16 | function actionHelp() { |
17 | 17 | printf "Available commands:\n" |
18 | 18 |
|
19 | | - printf " status Status of services\n" |
20 | | - printf " restart Restart services\n" |
21 | | - printf " start Start services\n" |
22 | | - printf " stop Stop services\n" |
23 | | - printf " build Build and start services\n" |
24 | | - printf " rebuild Run EspoCRM rebuild\n" |
25 | | - printf " upgrade Upgrade all EspoCRM services\n" |
26 | | - printf " clean Remove old and unused data\n" |
27 | | - printf " logs See the EspoCRM container logs\n" |
28 | | - printf " backup Backup all EspoCRM services\n" |
29 | | - printf " restore Restore the backup\n" |
30 | | - printf " import-sql Import database data by SQL dump\n" |
31 | | - printf " export-sql Export database data into SQL dump\n" |
32 | | - printf " cert-generate Generate a new Let's Encrypt certificate\n" |
33 | | - printf " cert-renew Renew an existing Let's Encrypt certificate\n" |
34 | | - printf " apply-domain Apply a domain change\n" |
35 | | - printf " help Information about the commands\n" |
| 19 | + printf " status Status of services\n" |
| 20 | + printf " restart Restart services\n" |
| 21 | + printf " start Start services\n" |
| 22 | + printf " stop Stop services\n" |
| 23 | + printf " build Build and start services\n" |
| 24 | + printf " rebuild Run EspoCRM rebuild\n" |
| 25 | + printf " upgrade Upgrade all EspoCRM services\n" |
| 26 | + printf " clean Remove old and unused data\n" |
| 27 | + printf " logs See the EspoCRM container logs\n" |
| 28 | + printf " backup Backup all EspoCRM services\n" |
| 29 | + printf " restore Restore the backup\n" |
| 30 | + printf " import-sql Import database data by SQL dump\n" |
| 31 | + printf " export-sql Export database data into SQL dump\n" |
| 32 | + printf " export-table-sql Export a single database table into SQL dump\n" |
| 33 | + printf " cert-generate Generate a new Let's Encrypt certificate\n" |
| 34 | + printf " cert-renew Renew an existing Let's Encrypt certificate\n" |
| 35 | + printf " apply-domain Apply a domain change\n" |
| 36 | + printf " help Information about the commands\n" |
36 | 37 | } |
37 | 38 |
|
38 | 39 | function promptConfirmation() { |
@@ -370,7 +371,7 @@ function actionExportSql() { |
370 | 371 | local fileName=${3:-"espocrm"} |
371 | 372 |
|
372 | 373 | if [ -z "$backupPath" ]; then |
373 | | - echo "ERROR: Path is not specified, ex. /var/www/backup." |
| 374 | + echo "ERROR: The path is not specified, ex. export-sql /var/www/backup" |
374 | 375 | exit 1 |
375 | 376 | fi |
376 | 377 |
|
@@ -416,13 +417,43 @@ function actionExportSql() { |
416 | 417 | } |
417 | 418 | fi |
418 | 419 |
|
419 | | - echo "Done. Saved to $backupPath" |
| 420 | + local backupPathArchived="$backupPath.tar.gz" |
| 421 | + |
| 422 | + tar -czf "$backupPathArchived" -C $(dirname "$backupPath") $(basename "$backupPath") > /dev/null 2>&1 || { |
| 423 | + echo "Done." |
| 424 | + echo "Saved to $backupPath" |
| 425 | + |
| 426 | + return |
| 427 | + } |
| 428 | + |
| 429 | + rm -f "$backupPath" |
| 430 | + |
| 431 | + echo "Done." |
| 432 | + echo "Saved to $backupPathArchived" |
| 433 | +} |
| 434 | + |
| 435 | +function actionExportTableSql() { |
| 436 | + local backupPath=${1:-} |
| 437 | + local tableName=${2:-} |
| 438 | + |
| 439 | + if [ -z "$backupPath" ]; then |
| 440 | + echo "ERROR: The path is not specified, ex. export-table-sql /var/www/backup account" |
| 441 | + exit 1 |
| 442 | + fi |
| 443 | + |
| 444 | + if [ -z "$tableName" ]; then |
| 445 | + echo "ERROR: Table name is not specified, ex. export-table-sql /var/www/backup account" |
| 446 | + exit 1 |
| 447 | + fi |
| 448 | + |
| 449 | + actionExportSql "$backupPath" "$tableName" "$tableName" |
420 | 450 | } |
421 | 451 |
|
422 | 452 | homeDirectory="$(dirname "$(readlink -f "$BASH_SOURCE")")" |
423 | 453 |
|
424 | 454 | action=${1:-help} |
425 | 455 | option=${2:-} |
| 456 | +option2=${3:-} |
426 | 457 |
|
427 | 458 | case "$action" in |
428 | 459 | help ) |
@@ -492,4 +523,8 @@ case "$action" in |
492 | 523 | export-sql ) |
493 | 524 | actionExportSql "$option" |
494 | 525 | ;; |
| 526 | + |
| 527 | + export-table-sql ) |
| 528 | + actionExportTableSql "$option" "$option2" |
| 529 | + ;; |
495 | 530 | esac |
0 commit comments