Skip to content

Commit 94aa869

Browse files
committed
domain for scp
1 parent 1711844 commit 94aa869

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: backup_one_local_instance/backup_wordpress.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ function get_config_parameters {
4040
# Produces a backup of full database in a tar.gz file
4141

4242
function mysql_dump {
43+
ssh $backup_user@$backup_host "mkdir -p $backup_remote_dir/$domain"
4344
mysqldump --user $db_user --password=$db_password \
4445
$db_name | gzip -c | ssh $backup_user@$backup_host "cat > \
45-
$backup_remote_dir/$(date +%Y%m%d)$db_name.sql.gz" \
46+
$backup_remote_dir/$domain/$(date +%Y%m%d)$db_name.sql.gz" \
4647
|| iferror "Backup for database named $db_name has failed" \
4748
&& wp_simple_backup_files;
4849
}
4950
# function: wp_simple_backup_files
5051
# Produces a tar.gz to a remote host
5152

5253
function wp_simple_backup_files {
53-
targz_file="/tmp/$(date +%Y%m%d)$domain.tar.gz";
54+
wp_targz="/tmp/$(date +%Y%m%d)$domain.tar.gz";
5455
if [[ -d $wp_path ]]; then
55-
tar czfp $targz_file -C $wp_path - \
56-
&& scp "$targz_file" $backup_user@$backup_host:$backup_remote_dir/. \
56+
tar czfp $wp_targz -C $wp_path . \
57+
&& scp $wp_targz $backup_user@$backup_host:$backup_remote_dir/$domain/. \
5758
&& rm -f $targz_file \
5859
|| iferror "Backup file not sended to $backup_host"
5960
fi
@@ -64,7 +65,7 @@ function wp_simple_backup_files {
6465
function nginx_site_backup {
6566
if [[ -e /etc/nginx/sites-enabled/$domain.conf ]]; then
6667
scp /etc/nginx/sites-enabled/$domain.conf \
67-
$backup_user@$backup_host:$backup_remote_dir/.
68+
$backup_user@$backup_host:$backup_remote_dir/$domain/.
6869
fi
6970
}
7071

0 commit comments

Comments
 (0)