Documentation

Comparing and synchronizing folders

MagnumOpus Diff can compare two whole folders and synchronize them. Typical uses: deploying a website from a local project to an SFTP or FTP server, checking what changed on production, pulling a backup from a server or a phone, or comparing two copies of a project.

Folder compare is in beta and is on by default. You can turn it off in Settings > Tools > Folder compare and synchronization (beta). It is in the Tools menu (the button next to the main menu), in the context menu of two selected folders and on the divider between two panes.

Opening a comparison

Two panes side by side with the Compare folders button and its tooltip on the divider

From the explorer:

  1. Split the window and open one folder in each pane.
  2. Choose Compare folders (MagnumOpus Diff)… in the command palette, or the button of the same name in the Select differences dialog (Shift+F2).

The left (or top) pane of the layout goes to the left side. A virtual folder (This PC, search results) cannot be compared. Scripts can use the command diff.compare-folders.

From the terminal:

mo-diff --dir D:\Projects\shop sftp://production/var/www/shop
mo-diff --profile=shop

Each side can be a local folder, a network share, an archive (read only), an SFTP / FTP server or a phone. Both paths can also be edited right in the window.

Reading the comparison

Folder compare in MagnumOpus Diff: a project against its backup, the Update, Two-way and Mirror modes, filters, the Action column with arrows and the synchronization plan at the bottom

Both sides are in one table, next to each other, with the rows aligned by their relative path. Flat list switches between a folder tree and a list of relative paths; Expand all and Collapse all work on the tree. Files and folders have their system icons.

The name color shows the state of each item:

StateMeaning
samenothing differs by the selected criteria
differentthe files differ, but neither side is newer
newer on left / newer on rightone side has a newer version
left only / right onlythe item exists on one side
conflictthe right action can't be decided automatically
ignoredmatches an ignore mask

A folder sums up its contents: it is different when anything inside is. The status bar counts items by state.

Above the table, the filter buttons All, Differences, Left only, Right only and Conflicts show their counts, and the name filter narrows the list by a mask or part of a name (*.php, config). Show ignored brings ignored items back into the list.

The filters Time only and Content differs next to Differences separate files with identical content that differ only in modification time from those whose content really differs. They need content comparison; if it is off, they switch it on for suspicious files and compare again in the background.

Comparing runs in the background and the rows appear as folders are read. Two trees of 100,000 files each are compared in about 0.1 s on a local disk. Compare again reads both sides once more.

A double click on a file opens the two files in a file comparison, where you can also edit them. A file from a server is downloaded to a temporary copy first.

Comparison criteria

Criteria… opens the comparison criteria. They are saved with the profile.

  • Size and modified time - the default. Time tolerance: exact, 2 s (FAT), 1 min (FTP) or 1 h.
  • Ignore hour shifts - times that differ by whole hours count as the same (time zones, daylight saving time on servers).
  • Content: don't compare, suspicious only (same size, different time - typical after a git checkout or unpacking an archive), or always.
  • Ignore - masks, one per line. .git, node_modules and similar folders are ignored by default.
  • Protected - never delete or overwrite - for example uploads/, cache/ or .env on a web server.

Masks work like this:

node_modules        a name at any depth
*.tmp               a name at any depth
cache/              folders only
config/local.php    a path from the root of the side

Choosing what happens

The mode decides the action for every item:

ModeWhat it does
Update →copies new and newer files from left to right
Update ←copies new and newer files from right to left
Two-waycopies new and newer files in both directions
Mirror →makes the right side the same as the left, including deletion
Mirror ←makes the left side the same as the right, including deletion

The Action column shows what synchronization will do with each item before you start. Click a cell to change the action, or use the keys . and , (copy right / left), Del (delete), Space (do nothing) and Backspace (back to what the mode decided) - also for a whole folder, which applies to everything inside. Mirror mode shows in this column what will disappear from the target, before you get to the preview.

A conflict is never resolved by itself: choose an action for it, or open the two files and decide there.

Acting on selected items only

You don't have to synchronize everything. Select files or folders and copy only them to the right or left, delete them on one side, leave them out, or put them back to the automatic action - with the bar below the table, the right-click menu (also Compare content and show in folder) or the keys Ctrl+Left / Ctrl+Right (copy in that direction) and Ctrl+Shift+Left / Ctrl+Shift+Right (delete on that side). Copying and deleting first show a preview for the selected items only and can be undone.

Synchronizing

  1. Click Synchronize…. A preview always comes first.
  2. The preview groups the plan by action - Create folders, Copy to the right (new), Overwrite on the right, Delete on the right and so on - with counts and sizes. Deletions and overwrites are red, conflicts are skipped.
  3. Check Verify after writing (xxh3) and Back up overwritten and deleted items (Undo). Change individual items in the Action column.
  4. A larger deletion needs the tick I understand: N items will be deleted. The button says the worst consequence, for example Run - deletes 37 items.
  5. Progress runs in the MagnumOpus Copy window, where you can pause and cancel. The folders are compared again when it finishes.

What happens behind the scenes:

  • Every item is checked again right before writing. When it changed since the comparison, it is skipped and reported.
  • Files are written under a temporary name and verified, so the target is never half-written - important for a running website.
  • A file uploaded to a server keeps the modified time of its source (SFTP, and FTP servers with MFMT / MDTM).
  • Deletions come last, and only when no copy failed.
  • A side that cannot be read never causes deletions on the other side.
  • Overwritten and deleted items are backed up, so Undo in the result restores them. Backups take at most 5 runs and 2 GB per profile; you can see them in Settings > Storage.

Profiles

Save profile stores both paths, the criteria, the mode and the actions you changed by hand. Profiles live in %APPDATA%\MagnumOpus\sync\<name>.toml, server passwords never go there. Open a saved profile with mo-diff --profile=<name>.

Two-way synchronization with a profile remembers the state after the last run. Then it recognizes:

  • a file deleted on one side since then - and deletes it on the other one too,
  • a file changed on both sides - and reports a conflict instead of letting the newer one win.

Without a profile, or before the first synchronization, the newer file wins and nothing is deleted.

Synchronizing from scripts

mo diff --sync runs a saved profile without a window:

mo diff --sync shop --plan
mo diff --sync shop --plan --json
mo diff --sync shop --run --yes
mo diff --sync shop --run --yes --allow-delete --max-delete=500
  • --plan lists the plan: + new, ~ overwrite, - delete, ? conflict. --json gives the same as JSON.
  • --run --yes performs the plan with the same checks and backups as the window.
  • Deletions run only with --allow-delete; otherwise they are skipped.
  • A mass deletion - 100 or more items, or a tenth of a side (for example an empty build folder) - also needs --max-delete=N; otherwise nothing runs.
  • Only one synchronization of a profile runs at a time.
Exit codeMeaning
0done, or nothing to do
1errors
2wrong arguments or profile
9folder compare is off in Settings
10--plan: there is something to do
11deletions skipped (no --allow-delete)
12something was skipped because it changed since the comparison
13mass deletion without --max-delete=N - nothing was done
Something wrong or missing? Open an issue