Skip to content

Improve script robustness, fix edge cases, and pass shellcheck#11

Open
zbcoding wants to merge 6 commits intoGeczy:mainfrom
zbcoding:fix/confirmed-bugs
Open

Improve script robustness, fix edge cases, and pass shellcheck#11
zbcoding wants to merge 6 commits intoGeczy:mainfrom
zbcoding:fix/confirmed-bugs

Conversation

@zbcoding
Copy link
Copy Markdown

@zbcoding zbcoding commented Mar 17, 2026

Summary

This PR builds on the great work in #10 by @rogerb831 (and earlier contributions from @Cristy94 ), which added pigz support, interactive prompts, multi-distro detection, and comprehensive documentation. Those are really nice additions to the migration script.

This PR layers on some additional hardening and fixes a few edge cases discovered
while testing:

  • Add set -euo pipefail to catch errors early instead of silently continuing
  • Replace string-manipulation conditionals (${answer#[Yy]}) with clearer case
    statements for y/n prompts
  • Use $(id -u) instead of $EUID for better POSIX compatibility
    • Change StrictHostKeyChecking no to StrictHostKeyChecking accept-new (avoids
      silently accepting changed host keys — a potential security concern)
  • Add a disk space check before creating the backup
    • Check if ~/.ssh/authorized_keys exists locally before including it in the tar
      archive
  • Add mkdir -p ~/.ssh on the remote server before writing keys
  • Add </dev/null redirects for remote package-install commands to prevent them from consuming the backup stream piped over stdin
  • Track whether Docker was stopped and prompt to restart it on the source server
    after migration
  • Add SSH keepalive options to prevent disconnects during large transfers
  • Skip redundant backup creation if the archive already exists (e.g., from a previous interrupted run) - Clean up authorized_keys_backup temp file and set proper permissions on ~/.ssh
  • Add a final success message
  • Pass shellcheck cleanly (with targeted disable comments where needed)

Test plan

  • Run migration on a test Coolify instance (Debian-based)
  • Verify pigz install prompt and fallback to gzip both work
  • Verify backup skips creation when archive already exists
  • Verify Docker restart prompt appears on source server
  • Confirm authorized_keys are correctly merged on destination
  • Test with low disk space to confirm warning triggers

🤖 Generated with Claude Code

Cristy94 and others added 6 commits November 5, 2025 01:44
Added support for parallel compression and decompression using pigz if available.
Pull in changes from Cristy94/coolify-migration
- Add early pigz detection with auto-install option and OS detection
- Add interactive prompts for sshKeyPath and destinationHost if defaults are used
- Fix missing quotes around variables to prevent word splitting
- Add comprehensive error handling for Docker commands
- Add error handling for authorized_keys operations
- Add fallback for nproc command
- Fix OS detection patterns for consistency
- Improve error messages and validation
- Fix syntax issues and indentation problems
- Add detailed overview and features section
- Include prerequisites and installation instructions
- Document configuration options and usage
- Add troubleshooting guide for common issues
- Include safety considerations and best practices
- Document supported operating systems
- Add contributing guidelines
- Include table of contents for easy navigation
@zbcoding zbcoding changed the title Title: Improve script robustness, fix edge cases, and pass shellcheck #11 Improve script robustness, fix edge cases, and pass shellcheck Mar 17, 2026
@zbcoding zbcoding changed the title #11 Improve script robustness, fix edge cases, and pass shellcheck Improve script robustness, fix edge cases, and pass shellcheck Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants