Synchronize a project directory to a remote host using
rsync and validate changes safely with a dry run.
Use push and pull workflows to keep backups current and to
restore content when needed.
You are backing up a local project directory to a remote
server. Your job is to push project_files/ to a
remote backup location, preview changes before syncing, and
then pull updates from the remote backup back into your local
directory to simulate a restore workflow.
rsync is a default tool for backups and safe
deployments because it is incremental and can preview its
actions. A dry run helps prevent accidental overwrites and
gives you evidence of what will change before you write.
project_files/ to a
remote backup path.
-a): recursive copy plus
preservation of key metadata.
-n): validates intent without touching
the destination.
project_files/ to the remote backup path.
rsync -avz project_files/ student@remote.server.com:/home/student/backup/
-a enables archive mode, -v prints
what is being transferred, and -z compresses
data over the network. The trailing slash on
project_files/ means “sync the contents of this
directory.”
sending incremental file list
./
index.html
config.yaml
sent 2,048 bytes received 64 bytes 4,224.00 bytes/sec
total size is 1,984 speedup is 0.92
rsync -avzn project_files/ student@remote.server.com:/home/student/backup/
The -n option shows what would change without
writing. This is where you catch mistakes in source/dest
paths before overwriting files on the remote side.
(DRY RUN) sending incremental file list
new_file.txt
(DRY RUN) total size is 512 speedup is 1.00
rsync -avz student@remote.server.com:/home/student/backup/ project_files/
This “pull” pattern is common during restores or when
synchronizing from a canonical remote copy. The trailing
slash on project_files/ keeps the restore
confined to that directory.
receiving incremental file list
new_file.txt
sent 128 bytes received 2,048 bytes 4,352.00 bytes/sec
total size is 512 speedup is 0.94
Stop and re-run with -n. Most “rsync disasters”
come from an incorrect destination path or missing trailing
slash on the source.
Confirm the correct user and host, then validate SSH access. If a new host key appears unexpectedly, verify it through a trusted channel before accepting.
Permissions on the remote path may block writes, or local files may be unreadable. Fix permissions and re-run; rsync will only transfer what is missing or changed.
If you ever add deletion behavior, validate with a dry run first. Deletion flags are powerful and should be treated as high-risk changes.
Cleanup is confirming your local directory still contains what you expect and that your remote destination has the right structure. If this was a test run, remove the temporary file you introduced.
ls -la project_files/
# If you created a test file:
# rm -f project_files/new_file.txt
Dry run output matches your intent, sync completes without path surprises, and repeated runs show minimal/no changes.
rsync -a
: Archive mode (recursive copy + preserves permissions,
timestamps, and other metadata).
-a
: Equivalent to common preserve flags (recursive + keep
key attributes).
rsync -v
: Verbose output (shows what rsync is transferring).
-v
: Prints files and summary stats during sync.
rsync -z
: Compress file data during the transfer.
-z
: Useful over slower links; may be unnecessary on fast
LANs.
rsync -n
: Dry run (preview what would change without copying).
-n
: Use before any high-risk sync (new destination, new
flags, or uncertain paths).
user@host:/path/
: Remote target syntax when using rsync over SSH.
source/
: A trailing slash means “sync the contents of the
directory,” not the directory itself.