Rehearse the Folder Move Locally

LinuxBeginner
Practice Now

Introduction

A book conservation team is moving the Garden Atlas to a new desk. The source has private drafts and temporary previews; the receiver already has a note that cannot be lost. Your result is a usable collection and desk listing, first for today and then for a revised edition.

You need basic terminal familiarity. This independent environment supplies both local folders and a next-edition snapshot. You will learn direction, trailing slashes, dry runs, filters and precise deletion scope before applying the same ideas over SSH in the next lab.

Rehearse the Collection Boundary

In this step, you will copy the book collection into the receiving folder after comparing two safe previews. Use the Terminal throughout this lab. No SSH is needed here.

The conservation desk is moving a Garden Atlas. old/collection holds text, a hidden reading configuration and an executable reader. old/generated holds disposable desk listings. old/personal is private. The new desk already has receiver-note.txt; that belongs to the receiving team and must survive every update. revision/ contains the supplied next edition, for later use.

cd changes directory. ls -a includes hidden entries; cat reads text without editing it. Start by seeing the receiving team's note:

cd /home/labex/project/folder-move
ls -a old/collection
cat new/receiver-note.txt

The note says Received by Mira. Keep the west shelf clear. The older catalog already on this desk is incomplete. The destination is intentionally not empty.

rsync copies from its first path to its second. -a means archive mode: it recursively copies directories and preserves modification times, executable permissions and other supported attributes. An ordinary receiving account cannot retain arbitrary source owners; this course checks bytes and execution permission, not cross-system ownership, ACLs or extended attributes. -n makes a dry run, so no files change. -i lists proposed changes item by item.

The quoted exclusion keeps names ending in .tmp out at every depth; quotes prevent the shell expanding the pattern before rsync sees it.

First preview the source directory itself, without a trailing slash:

rsync -ani --exclude='*.tmp' old/collection new/collection/

Look for a proposed extra collection/ inside the destination collection. That nesting would place the reader in the wrong place.

Now preview the source contents, with a trailing slash:

rsync -ani --exclude='*.tmp' old/collection/ new/collection/

Now the paths belong directly under new/collection/, including .bindery.conf, read-book and texts/. A dot file is included because rsync sees the directory itself; using a shell wildcard such as old/collection/* would omit hidden entries. New regular files commonly show >f+++++++++; other flags describe changed attributes. Dry-run lines describe proposals, not a delivered collection.

Remove only n to execute the chosen transfer:

rsync -ai --exclude='*.tmp' old/collection/ new/collection/
new/collection/read-book

The reader prints reading_order=catalog,treatment, then the Garden Atlas catalog and paper-hinge treatment. Direct execution proves that the copied reader works with its relative text paths and hidden configuration. If execution is denied, inspect the source and destination modes with ls -l; rerun archive mode from the prepared source. Do not replace the reader with fixed output.

If you accidentally performed the nested copy, inspect ls new/collection/collection before removing only that accidental duplicate with rm -r new/collection/collection. rm -r removes the named directory and its contents permanently. Never shorten this cleanup to new, which also holds the receiving note. Then rerun the correct transfer.

Deliver the Desk Listing without Deleting Notes

In this step, you will complete the first delivery by copying the separate generated listing. Stay in Terminal, in /home/labex/project/folder-move.

The collection and generated files have different responsibilities. The source owns every file under generated/; the receiver owns its root note. Select just the second managed directory instead of copying old/ wholesale, which would also disclose personal/.

rsync -ani old/generated/ new/generated/
rsync -ai old/generated/ new/generated/
cat new/generated/current.txt
cat new/receiver-note.txt

The listing says Garden Atlas | desk edition 1. The obsolete listing is deliberately still part of edition 1. The receiving note has not changed. Read the delivered reader again:

new/collection/read-book

No --delete has been needed. By default, rsync keeps destination-only files. An exclusion prevents transfer; it does not remove a temporary file that is already at the destination. If you previously copied a preview by mistake, inspect and remove only the exact unwanted file, such as rm new/collection/preview.tmp; then retry the filtered synchronization. Never clean the receiving root to make the check pass.

Apply the Next Edition within the Managed Scope

In this step, you will deliver a second edition and retire only the old generated listing. Stay in Terminal in the same workspace.

cat accepts several filenames and prints them in that order. Read the supplied next edition before replacing the editable source:

cat revision/collection/texts/catalog.txt revision/collection/texts/treatment.txt revision/collection/texts/addendum.txt

The catalog now has 48 folios, the treatment uses linen hinges, and an addendum is new. cp -a copies recursively while preserving file attributes. revision/. means all contents, including hidden files. This overlays supplied changes onto old/; it does not remove an entry absent from the revision. The desk explicitly retires old/generated/obsolete.txt, so remove that one named source file. rm deletes a file permanently; do not widen the path.

cp -a revision/. old/
rm old/generated/obsolete.txt

Normally rsync decides whether file data changed from size and modification time. -c adds a checksum comparison of file content. These tiny files make the cost small, and this also detects equal-size changes with preserved timestamps. It does not make a version history or backup. Preview and apply the collection update:

rsync -anci --exclude='*.tmp' old/collection/ new/collection/
rsync -aci --exclude='*.tmp' old/collection/ new/collection/

The collection preview should show the two revised texts and the new addendum, without temporary previews. Attribute-only changes may also appear.

--delete removes destination entries absent from the source within the chosen synchronization directory. Here only generated/ is wholly managed; the receiving root is not. Preview its retirement, looking for *deleting obsolete.txt, then apply exactly the same scope:

rsync -anci --delete old/generated/ new/generated/
rsync -aci --delete old/generated/ new/generated/
cat new/generated/current.txt new/collection/texts/addendum.txt new/receiver-note.txt
new/collection/read-book

You should read desk edition 2, the new folio, the original receiving note and the updated reader output. A root-wide mirror with --delete could erase the note. Never use it to retire this one managed listing.

Repeat the same previews:

rsync -anci --exclude='*.tmp' old/collection/ new/collection/
rsync -anci --delete old/generated/ new/generated/

There should be no remaining file changes. A repeat is safe for this declared scope, but a later source deletion would still require a deliberate decision about which destination directory is managed. The original edition is not recoverable from rsync alone; use a separate backup when history matters.

Summary

You delivered a usable collection, kept its hidden configuration and reader permissions, and preserved the receiving desk note. A second synchronization updated the managed files and removed a retired listing only within its declared scope. Synchronization is directional; it is not a versioned backup or conflict merger.