mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
fix: zbackup_ec2/zec2/zec2online require an explicit target (all), matching zbackup (#11)
These three defaulted to "every project" when run with no arguments - inconsistent with zbackup/zdeploy/zstart/etc. (which show usage), and a surprising amount of work to kick off by accident: zbackup_ec2 pulls a server backup of every project, and zec2online deep-checks everything AND auto-starts any downed stacks. Now a bare invocation prints usage and lists the projects; 'all' does what bare used to. Applied to both the bash and PowerShell versions.
This commit is contained in:
parent
845e89a9b3
commit
b370a46d79
@ -7,8 +7,8 @@
|
|||||||
# with a "db" config block, plus a zip of server-side data dirs (uploads/archive/dist).
|
# with a "db" config block, plus a zip of server-side data dirs (uploads/archive/dist).
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zbackup_ec2 # every project with a remote.path
|
|
||||||
# zbackup_ec2 <project> [<project> ...]
|
# zbackup_ec2 <project> [<project> ...]
|
||||||
|
# zbackup_ec2 all # every project with a remote.path
|
||||||
#
|
#
|
||||||
# Output:
|
# Output:
|
||||||
# <paths.backupsEc2>/<project>/<timestamp>_<project>_db.sql (projects with a db block)
|
# <paths.backupsEc2>/<project>/<timestamp>_<project>_db.sql (projects with a db block)
|
||||||
@ -21,7 +21,14 @@ z_need_config
|
|||||||
z_require ssh scp
|
z_require ssh scp
|
||||||
|
|
||||||
projects=("$@")
|
projects=("$@")
|
||||||
|
# Require an explicit target; 'all' pulls every project with a remote.path.
|
||||||
if [ "${#projects[@]}" -eq 0 ]; then
|
if [ "${#projects[@]}" -eq 0 ]; then
|
||||||
|
printf '\n'; warn "Usage: zbackup_ec2 <project> [<project> ...] | all"
|
||||||
|
dim " Projects in zconfig.json: $(zproj_csv)"
|
||||||
|
dim " 'all' pulls a server backup of every project with a remote.path."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if printf '%s\n' "${projects[@]}" | grep -qx 'all'; then
|
||||||
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done \
|
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done \
|
||||||
< <(jq -r '.projects | to_entries[] | select((.key | startswith("_") | not) and .value.remote.path != null) | .key' "$ZCONFIG")
|
< <(jq -r '.projects | to_entries[] | select((.key | startswith("_") | not) and .value.remote.path != null) | .key' "$ZCONFIG")
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
# zec2 — quick reachability check (TCP + HTTP + live build version) for deployed projects.
|
# zec2 — quick reachability check (TCP + HTTP + live build version) for deployed projects.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zec2 # every project with a "domain" in zconfig.json
|
|
||||||
# zec2 <project> [<project> ...]
|
# zec2 <project> [<project> ...]
|
||||||
|
# zec2 all # every project with a "domain" in zconfig.json
|
||||||
# zec2 viteapp --host 203.0.113.10
|
# zec2 viteapp --host 203.0.113.10
|
||||||
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
@ -28,6 +28,12 @@ done
|
|||||||
HOST="${host_override:-$(zec2_ip)}"
|
HOST="${host_override:-$(zec2_ip)}"
|
||||||
|
|
||||||
if [ "${#projects[@]}" -eq 0 ]; then
|
if [ "${#projects[@]}" -eq 0 ]; then
|
||||||
|
printf '\n'; warn "Usage: zec2 <project> [<project> ...] | all [--host <ip>]"
|
||||||
|
dim " Projects in zconfig.json: $(zproj_csv)"
|
||||||
|
dim " 'all' checks every project with a 'domain' configured."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if printf '%s\n' "${projects[@]}" | grep -qx 'all'; then
|
||||||
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done < <(zproj_keys_with_domain)
|
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done < <(zproj_keys_with_domain)
|
||||||
if [ "${#projects[@]}" -eq 0 ]; then
|
if [ "${#projects[@]}" -eq 0 ]; then
|
||||||
warn "No projects with a 'domain' configured in zconfig.json."
|
warn "No projects with a 'domain' configured in zconfig.json."
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
# build; auto-start downed stacks via docker compose and stream diagnostics.
|
# build; auto-start downed stacks via docker compose and stream diagnostics.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zec2online # every project with a "domain" in zconfig.json
|
|
||||||
# zec2online <project> [<project> ...]
|
# zec2online <project> [<project> ...]
|
||||||
|
# zec2online all # every project with a "domain" in zconfig.json
|
||||||
#
|
#
|
||||||
# A plain HTTP-200 check passes even when a stale cached build is live — the
|
# A plain HTTP-200 check passes even when a stale cached build is live — the
|
||||||
# local-vs-server version match is what proves the deployed build is the one running.
|
# local-vs-server version match is what proves the deployed build is the one running.
|
||||||
@ -32,6 +32,12 @@ HOST="${host_override:-$(zec2_ip)}"
|
|||||||
EDGE_KEY="$(zedge_key)"
|
EDGE_KEY="$(zedge_key)"
|
||||||
|
|
||||||
if [ "${#projects[@]}" -eq 0 ]; then
|
if [ "${#projects[@]}" -eq 0 ]; then
|
||||||
|
printf '\n'; warn "Usage: zec2online <project> [<project> ...] | all [--host <ip>]"
|
||||||
|
dim " Projects in zconfig.json: $(zproj_csv)"
|
||||||
|
dim " 'all' deep-checks every project with a 'domain' (and auto-starts any that are down)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if printf '%s\n' "${projects[@]}" | grep -qx 'all'; then
|
||||||
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done < <(zproj_keys_with_domain)
|
projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done < <(zproj_keys_with_domain)
|
||||||
if [ "${#projects[@]}" -eq 0 ]; then
|
if [ "${#projects[@]}" -eq 0 ]; then
|
||||||
warn "No projects with a 'domain' configured in zconfig.json."
|
warn "No projects with a 'domain' configured in zconfig.json."
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
# with a "db" config block, plus a zip of server-side data dirs (uploads/archive/dist).
|
# with a "db" config block, plus a zip of server-side data dirs (uploads/archive/dist).
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zbackup_ec2 # every project with a remote.path
|
|
||||||
# zbackup_ec2 <project> [<project> ...]
|
# zbackup_ec2 <project> [<project> ...]
|
||||||
|
# zbackup_ec2 all # every project with a remote.path
|
||||||
#
|
#
|
||||||
# Output:
|
# Output:
|
||||||
# <paths.backupsEc2>\<project>\<timestamp>_<project>_db.sql (projects with a db block)
|
# <paths.backupsEc2>\<project>\<timestamp>_<project>_db.sql (projects with a db block)
|
||||||
@ -29,6 +29,13 @@ $RemoteHome = Get-Ec2Home
|
|||||||
$Ec2BackupRoot = $cfg.paths.backupsEc2
|
$Ec2BackupRoot = $cfg.paths.backupsEc2
|
||||||
|
|
||||||
if ($Projects.Count -eq 0) {
|
if ($Projects.Count -eq 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Usage: zbackup_ec2 <project> [<project> ...] | all" -ForegroundColor Yellow
|
||||||
|
Write-Host " Projects in zconfig.json: $((Get-ZProjectKeys) -join ', ')" -ForegroundColor Gray
|
||||||
|
Write-Host " 'all' pulls a server backup of every project with a remote.path." -ForegroundColor Gray
|
||||||
|
Stop-ZTracking; exit 1
|
||||||
|
}
|
||||||
|
if ($Projects -contains 'all') {
|
||||||
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.remote -and $cfg.projects.$_.remote.path })
|
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.remote -and $cfg.projects.$_.remote.path })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
zec2.ps1
9
zec2.ps1
@ -5,8 +5,8 @@
|
|||||||
# zec2.ps1 — quick reachability check (TCP + HTTP + live build version) for deployed projects.
|
# zec2.ps1 — quick reachability check (TCP + HTTP + live build version) for deployed projects.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zec2 # every project with a "domain" in zconfig.json
|
|
||||||
# zec2 <project> [<project> ...]
|
# zec2 <project> [<project> ...]
|
||||||
|
# zec2 all # every project with a "domain" in zconfig.json
|
||||||
# zec2 viteapp -HostName 203.0.113.10
|
# zec2 viteapp -HostName 203.0.113.10
|
||||||
#
|
#
|
||||||
param(
|
param(
|
||||||
@ -23,6 +23,13 @@ $cfg = Get-ZConfig
|
|||||||
if (-not $HostName) { $HostName = $cfg.ec2.ip }
|
if (-not $HostName) { $HostName = $cfg.ec2.ip }
|
||||||
|
|
||||||
if ($Projects.Count -eq 0) {
|
if ($Projects.Count -eq 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Usage: zec2 <project> [<project> ...] | all [-HostName <ip>]" -ForegroundColor Yellow
|
||||||
|
Write-Host " Projects in zconfig.json: $((Get-ZProjectKeys) -join ', ')" -ForegroundColor Gray
|
||||||
|
Write-Host " 'all' checks every project with a 'domain' configured." -ForegroundColor Gray
|
||||||
|
Stop-ZTracking; exit 1
|
||||||
|
}
|
||||||
|
if ($Projects -contains 'all') {
|
||||||
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.domain })
|
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.domain })
|
||||||
if ($Projects.Count -eq 0) {
|
if ($Projects.Count -eq 0) {
|
||||||
Write-Host "No projects with a 'domain' configured in zconfig.json." -ForegroundColor Yellow
|
Write-Host "No projects with a 'domain' configured in zconfig.json." -ForegroundColor Yellow
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
# build; auto-start downed stacks via docker compose and stream diagnostics.
|
# build; auto-start downed stacks via docker compose and stream diagnostics.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# zec2online # every project with a "domain" in zconfig.json
|
|
||||||
# zec2online <project> [<project> ...]
|
# zec2online <project> [<project> ...]
|
||||||
|
# zec2online all # every project with a "domain" in zconfig.json
|
||||||
#
|
#
|
||||||
# Verification compares the LOCAL build version against what the server is actually
|
# Verification compares the LOCAL build version against what the server is actually
|
||||||
# serving. A plain HTTP-200 check passes even when a stale cached build is live —
|
# serving. A plain HTTP-200 check passes even when a stale cached build is live —
|
||||||
@ -30,6 +30,13 @@ $SshTarget = Get-Ec2Target
|
|||||||
$edgeProj = Get-ZEdgeProject
|
$edgeProj = Get-ZEdgeProject
|
||||||
|
|
||||||
if ($Projects.Count -eq 0) {
|
if ($Projects.Count -eq 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Usage: zec2online <project> [<project> ...] | all [-HostName <ip>]" -ForegroundColor Yellow
|
||||||
|
Write-Host " Projects in zconfig.json: $((Get-ZProjectKeys) -join ', ')" -ForegroundColor Gray
|
||||||
|
Write-Host " 'all' deep-checks every project with a 'domain' (and auto-starts any that are down)." -ForegroundColor Gray
|
||||||
|
Stop-ZTracking; exit 1
|
||||||
|
}
|
||||||
|
if ($Projects -contains 'all') {
|
||||||
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.domain })
|
$Projects = @(Get-ZProjectKeys | Where-Object { $cfg.projects.$_.domain })
|
||||||
if ($Projects.Count -eq 0) {
|
if ($Projects.Count -eq 0) {
|
||||||
Write-Host "No projects with a 'domain' configured in zconfig.json." -ForegroundColor Yellow
|
Write-Host "No projects with a 'domain' configured in zconfig.json." -ForegroundColor Yellow
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user