summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-24 17:33:20 -0400
committerroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-24 17:33:20 -0400
commit291d8b9c32e4dac1c4794444ca5bfc005f454dda (patch)
tree2ed10b58eee85816fd58519014b3d0d94fc1b3db
parenta6d32e3398f2ec1913bbdb75b172c96724d04a57 (diff)
improve rsync-push
-rwxr-xr-xwordpress/wordpress-rsync-push-site50
1 files changed, 23 insertions, 27 deletions
diff --git a/wordpress/wordpress-rsync-push-site b/wordpress/wordpress-rsync-push-site
index 225a6c4..69a32c5 100755
--- a/wordpress/wordpress-rsync-push-site
+++ b/wordpress/wordpress-rsync-push-site
@@ -28,21 +28,21 @@ conf_file=/./etc/apache2/sites-available/$site.conf
28 28
29installer() 29installer()
30{ 30{
31 echo mysqlrestore "$1" 31 printf 'arg1=%s\n' "$1"
32 printf 'arg2=%s\n' "$2"
32} 33}
33 34
34installer_source_code() 35installer_source_code()
35{ 36{
36 echo '#!/bin/sh' 37 echo '#!/bin/sh'
37 declare -f installer 38 declare -f installer
38 echo "installer \"$1\"" 39 printf 'installer %q %q\n' "$1" "$2"
39} 40}
40 41
41do_rsync() 42do_rsync()
42{ ( 43{
43 set -x 44 rsync ${NO_ACT:+ -n} -u -aR --delete --partial "$conf_file" "$html_dir" "$remote_host":"$target_dir"/
44 rsync ${NO_ACT:+ -nv} -u -aRi --delete --partial "$conf_file" "$html_dir" "$remote_host":/"$target_dir" 45}
45) }
46 46
47remote_mysqldump() 47remote_mysqldump()
48{ 48{
@@ -55,28 +55,24 @@ remote_mysqldump()
55} 55}
56 56
57do_mysqldump() 57do_mysqldump()
58{ ( 58{
59 case "$NO_ACT" in 59 of=$target_dir/srv/$site/wordpress-database~"$(date -Ins)".sql.gz
60 '') of=/srv/$site/wordpress-database~"$(date -Ins)".sql.gz ;; 60
61 * ) of=/dev/null ;; 61 dumpfile=$(mktemp -p "$XDG_RUNTIME_DIR") || dumpfile=$(mktemp)
62 esac 62 remote_mysqldump | gzip -c > "$dumpfile"
63 oftest=/srv/$site/wordpress-database~"$(date -Ins)".sql.gz 63 rsync ${NO_ACT:+ -n} --ignore-existing "$dumpfile" "$remote_host":"$of"
64 printf '%s\n' "$oftest" >&2 64 rm "$dumpfile"
65 installer_source_code "$oftest" >&2 65}
66 66
67 if [ "$use_rsync" ] 67do_installer()
68 then 68{
69 set -x 69 installer_exe=$(mktemp -p "$XDG_RUNTIME_DIR") || installer_exe=$(mktemp)
70 dumpfile=$(mktemp -p "$XDG_RUNTIME_DIR") || dumpfile=$(mktemp) 70 installer_source_code "$target_dir" "$of" > "$installer_exe"
71 remote_mysqldump | gzip -c > "$dumpfile" 71}
72 rsync --ignore-existing "$dumpfile" "$remote_host":"$of"
73 rm "$dumpfile"
74 else
75 set -x
76 remote_mysqldump | gzip -c | ssh "$remote_host" dd conv=notrunc "of=$of"
77 fi
78) }
79 72
73target_dir=/var/tmp/wordpress-rsync-push-site~$(date -Ins) NO_ACT=
74[ "$target_dir" ] || NO_ACT=y
80use_rsync=y 75use_rsync=y
81do_rsync 76do_rsync
82do_mysqldump 77do_mysqldump
78do_installer