mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 18:49:42 +08:00
39 lines
845 B
Bash
Executable file
39 lines
845 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Backups CaptainCore configurations to remote.
|
|
#
|
|
# `captaincore cli backup`
|
|
#
|
|
|
|
# Load configuration
|
|
root_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; root_path=${root_path%app*}
|
|
source ${root_path}lib/arguments
|
|
|
|
run_command() {
|
|
|
|
cd ${root_path}data
|
|
|
|
# Export crontab
|
|
crontab -l > backup_crontab.conf
|
|
|
|
# Export rclone configs
|
|
rclone_configs=$(rclone config file)
|
|
rclone_configs=${rclone_configs##*$'\n'}
|
|
cat $rclone_configs > backup_rclone.conf
|
|
|
|
# Export WordPress configs
|
|
wp db export --skip-plugins --skip-themes --add-drop-table - > wp-content/mysql.sql
|
|
chmod 600 wp-content/mysql.sql
|
|
|
|
# Create Archive
|
|
cd ~
|
|
rm captaincore_backup.zip
|
|
zip -r captaincore_backup.zip .captaincore
|
|
|
|
# Upload to remove
|
|
rclone sync captaincore_backup.zip ${rclone_cli_backup}/
|
|
|
|
}
|
|
|
|
run_command
|