mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 20:45:45 +08:00
37 lines
No EOL
1.2 KiB
Text
37 lines
No EOL
1.2 KiB
Text
# Store current path
|
|
home_directory=$(pwd)
|
|
private_directory=""
|
|
|
|
# Find private folder
|
|
if [ -d "_wpeprivate" ]; then
|
|
private_directory=${home_directory}/_wpeprivate
|
|
fi
|
|
|
|
if [ -d "../private" ]; then
|
|
cd ../private
|
|
private_directory=$(pwd)
|
|
cd $home_directory
|
|
fi
|
|
|
|
if [ -d "../tmp" ]; then
|
|
cd ../tmp
|
|
private_directory=$(pwd)
|
|
cd $home_directory
|
|
fi
|
|
|
|
if [[ "$private_directory" == "" ]]; then
|
|
echo "Can't find private folder. Database backup cancelled.";
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# get the wp-config.php variables
|
|
database_name=$( wp config get DB_NAME --skip-plugins --skip-themes )
|
|
database_username=$( wp config get DB_USER --skip-plugins --skip-themes )
|
|
database_password=$( wp config get DB_PASSWORD --skip-plugins --skip-themes )
|
|
|
|
# Perform DB backup with [emoji support](https://anchor.host/wp-cli-database-backups-with-emojis/) and [speed](https://guides.wp-bullet.com/how-to-export-large-wordpress-databases-and-speed-up-the-process/)
|
|
mysqldump -u ${database_username} -p${database_password} --max_allowed_packet=512M --default-character-set=utf8mb4 --add-drop-table --single-transaction --quick --lock-tables=false ${database_name} > ${private_directory}/database-backup.sql
|
|
|
|
# Make it safe
|
|
chmod 600 ${private_directory}/database-backup.sql |