Docker Cleanup Preview
Show reclaimable Docker space, then prune only with an explicit flag.
$ webtoolist --script deploy-with-rollback
Deploy a release directory and switch a symlink, keeping the previous release for rollback.
deploysymlinkrollbackreleaseDependencies: rsync, ln, date
#!/usr/bin/env bash
set -euo pipefail
src="${1:-}"
releases="${2:-}"
current="${3:-}"
apply=0
[[ ${4:-} == --apply ]] && apply=1
[[ -d "$src" && -n "$releases" && -n "$current" ]] || {
echo "usage: $0 RELEASE_DIR RELEASES_ROOT CURRENT_SYMLINK [--apply]" >&2
exit 1
}
stamp="$(date +%Y%m%d-%H%M%S)"
target="$releases/$stamp"
if ((apply)); then
mkdir -p "$target"
rsync -a --delete "$src"/ "$target"/
ln -sfn "$target" "$current"
echo "deployed: $target -> $current"
echo "previous release still available; roll back with:"
echo " ln -sfn \$(readlink -f \"$current\" | xargs dirname)/PREVIOUS \"$current\""
else
echo "would copy: $src/ -> $target/"
echo "would switch: $current -> $target"
echo "(dry run) re-run with --apply"
fi
./deploy-with-rollback ./dist /srv/app/releases /srv/app/current
./deploy-with-rollback ./dist /srv/app/releases /srv/app/current --apply
Related scripts
Show reclaimable Docker space, then prune only with an explicit flag.
Report branch, dirty state, and ahead/behind for every Git repo under a directory.