Skip to content

Commit ce7ba91

Browse files
committed
more robust db backup creation ( avoid permission issues )
1 parent cde71dc commit ce7ba91

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

functions.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -833,17 +833,14 @@ EOF
833833
# Add the necessary commands for full backups (append to file, note >>)
834834
cat <<EOF >>"$script_path"
835835
836-
# Get the wp installation folder owner and their home directory
836+
# Get the wp installation folder owner
837837
wp_owner=\$(sudo stat -c "%U" \${domain_path})
838-
wp_owner_directory=\$(sudo getent passwd \${wp_owner} | cut -d: -f6)
839838
840-
# if we can't find the owner directory, use /tmp as fallback
841-
if [ -z "\${wp_owner_directory}" ] || [ ! -d "\${wp_owner_directory}" ]; then
842-
wp_owner_directory="/tmp"
843-
fi
839+
# Use a dedicated temp directory for database backups
840+
wp_owner_directory="/tmp/wp_db_backup"
844841
845842
echo "[\${timestamp}] - WP folder owner found: '\${wp_owner}'" >> "$LOG_FILE"
846-
echo "[\${timestamp}] - WP folder owner home directory found: '\${wp_owner_directory}'" >> "$LOG_FILE"
843+
echo "[\${timestamp}] - Using temp directory: '\${wp_owner_directory}'" >> "$LOG_FILE"
847844
848845
# Create tmp directory with proper permissions if it doesn't exist
849846
if [ ! -d "\${wp_owner_directory}" ]; then

0 commit comments

Comments
 (0)