Skip to content

Instantly share code, notes, and snippets.

@sabrysuleiman
Last active April 12, 2025 18:09
Show Gist options
  • Save sabrysuleiman/84c900a3e317b6714bc55c90383e501d to your computer and use it in GitHub Desktop.
Save sabrysuleiman/84c900a3e317b6714bc55c90383e501d to your computer and use it in GitHub Desktop.
Website Migration Via SSH & SCP
# πŸ” Connect to Remote Server via SSH
# Establishes a secure SSH connection to a remote server using a specific port (e.g., 6543). Useful for accessing and managing remote systems.
ssh -p port [email protected]
ssh -p 6543 [email protected]
# πŸ“¦ Compress Website Directories into .tar.gz Archives
# Creates compressed .tar.gz archives of the uploads, themes, and plugins directories. Ideal for backup or transfer.
tar -czf uploads.tar.gz ./uploads
tar -czf themes.tar.gz ./themes
tar -czf plugins.tar.gz ./plugins
# πŸ—„οΈ Backup MySQL Database and Compress
# Exports a MySQL database into a .sql file using mysqldump, then compresses it into a .tar.gz archive.
mysqldump -u DB_USER -p DB_NAME > db.sql
tar -czf db.tar.gz db.sql
# πŸš€ Transfer Files to New Server via SCP
# Securely copies the uploads.tar.gz file to a remote server's public_html directory over a specific port using SCP.
scp -P port ./uploads.tar.gz [email protected]:~/public_html/
scp -P 6543 ./uploads.tar.gz [email protected]:~/public_html/
# 🧹 Clean Up Local Archive Files
# Removes the previously created .tar.gz files from the local system to free up space or tidy up after transfer.
rm ./uploads.tar.gz ./plugins.tar.gz ./themes.tar.gz`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment