How to Use Screen for Long File Transfers with Rsync

Learn how to use the screen command to keep your Rsync file transfer running even if your SSH session disconnects. This method ensures uninterrupted data transfers, making it ideal for large file movements.

Banner

Transferring large amounts of data over SSH can be risky, especially if your connection is unstable. If your SSH session disconnects, the transfer stops—unless you use screen. The screen command allows you to create a session, detach from it, and later reattach, ensuring uninterrupted file transfers.

Follow these steps to use screen with Rsync for long transfers: Step 1: Start a New Screen Session

Run the following command to create a new screen session named "copy-session":


screen -S copy-session

Step 2: Start the Rsync Transfer

Execute your Rsync command inside the screen session:


rsync -avh --progress /mnt/storage/my_vol/HDD/ /mnt/glusterfs-mount/

🔥 Now, even if your SSH connection drops, the process will keep running in the background! Step 3: Detach the Screen Session

To detach the session while keeping it running, press:

Ctrl + A, then D

✅ Now, the session is still active, and Rsync continues running in the background. Step 4: Reattach the Screen Session

If you log out or get disconnected, you can restore the session by running:


screen -r copy-session

This brings you right back to where you left off!

Why Use screen for Rsync?

Prevents SSH session interruptions from affecting long file transfers.
Keeps Rsync running in the background.
Allows you to resume progress even after disconnection.

Next time you need to transfer large files, use screen and ensure your transfer completes without interruptions! 🚀

How to Use Screen for Long File Transfers with Rsync | Software Engineer Blog