Documentation

Linking a folder to a server

A folder linked to a server gets an Upload changes button in the path bar. It uploads only what changed since the last upload - to an SFTP / FTP / FTPS server, WebDAV / S3 or a network folder - with progress in the button, Undo and a preview before anything is deleted or a newer file on the server is overwritten. Typical use: a website or an app you edit locally and deploy to a server.

The Link to server dialog: name, server and path, how changes are detected, how they are uploaded, steps before and after, and which files to ignore

Linking is on by default; it can be turned off in Settings > Servers and network > Link folders to servers (links stay saved). Any server from Settings > Servers and network can be a target.

Linking a folder

  1. Open the folder and choose Link to server... in the folder context menu or in the command palette.
  2. Fill in the Target: a server (from the saved servers) and the path on it, or a local / network folder. Browse... next to the path opens a dialog with the folders on the chosen server (it starts at the current path, or at the server's default folder); it is disabled until you choose a server.
  3. Choose how changes are found (Changes), how they are uploaded (Uploading) and which files go (Files). The question marks next to the fields explain each option.
  4. Save. The first upload follows (see below).

The same dialog edits an existing link: the Upload changes button menu or Link to server / edit link in the palette.

How changes are found

  • Memory + watching - the folder is watched; only local changes since the last upload are uploaded. Fast, the server is asked only about the files being uploaded.
  • Compare with server - every upload reads the server too, so it also finds changes made directly on the server. Slower.
  • Git (in a repository) - changes come from git: commits since the last upload, renames, submodules. Allowed branches limit where you can upload from (exact names, e.g. main; production); Upload uncommitted changes too adds work in progress.

Uploading

  • Directly with Undo - uploads right away with progress; a preview appears only when something is risky (deleting, overwriting a newer file, another branch).
  • Always preview - a short list to check before every upload.
  • Production (always preview) - for a server running the live site: always a preview, no automatic upload.
  • Delete files deleted locally on the server too - with a backup; mass deletes are always confirmed.
  • Upload automatically after saving a file - a batch of saved files is uploaded shortly after saving (only safe changes; deleting or overwriting a newer file waits for the button unless you allow it).

Undo in the notification after an upload (and Undo last upload in the button menu) returns the server to the state before the upload from the backup.

In daily use

  • The linked folder has a badge in the list and in the tree with the number of changes since the last upload (! = waiting for confirmation); the button shows the same. Settings > Servers and network > Badge of changes to upload turns the badge off.
  • Upload selected to (context menu, command link.upload-selected) uploads only the selected files and folders.
  • Automatic upload runs about 2 s after the last save, in one batch. More than 20 changes at once (switching a branch, a build) are only offered. An unavailable server is retried after 5 s, 30 s and 2 min. Pause automatic upload in the button menu (command link.pause-auto) stops it until the end of the session.
  • Only one upload of a link runs at a time, even when the folder is open in several windows. Uploads run in MagnumOpus Copy without a window; the window appears when an upload takes longer than 2 s.

The first upload

A new link does not know what is on the server yet. The First upload dialog offers:

  • Compare with server - the whole comparison opens in MagnumOpus Diff, where you see the differences and upload with a preview.
  • The server matches the current state - nothing is uploaded or compared by content; from now on only changes are uploaded. The state of the server is filled in by one listing.
  • In a git repository also "the server matches commit X".

Files

  • Ignore - what is never uploaded (masks like .gitignore: *.log anywhere, src/cache/ only there). Follow .gitignore ignores what git ignores.
  • Always upload - an exception from ignoring, typically build output (dist/).
  • Protected - never deleted or overwritten on the server (uploads of the website, the server .env).

Choose files... opens a tree of the local folder: each item is Upload / Ignore / Always upload and separately Protected; the Target (Protected) tab shows the server (or the target folder). Check recommended marks editor settings, dependencies, logs and system files as Ignore, secrets (.env, keys) as Ignore and Protected and uploaded website files as Protected - each with a reason. The count below shows how many files will be uploaded and ignored. The choice becomes masks of the fields; masks you wrote by hand stay. The mask fields also suggest local folders and files while you type.

Project settings (.magnumopus) and the .git folder are never uploaded.

Steps before and after the upload

A link can run steps before and after the upload (Steps before and after upload): a local command (build), a command on the server over SSH (php artisan cache:clear, SFTP servers only), a web address (warm-up, webhook), emptying a folder on the server (cache; emptying one outside the link root is always confirmed) or uploading an otherwise ignored folder (node_modules, as Update or Mirror (delete too), with a backup).

  • What a step before the upload changes (build output) is uploaded in the same run.
  • A step with Only when changed runs only when its files changed; it can also watch ignored files (src/** when only dist/ is uploaded) - a change there runs the build even when nothing else is to upload.
  • A failing step before the upload stops the upload. A step can be marked to run even after a failed upload (turning maintenance mode off) or after an automatic upload too.
  • Variables ${branch}, ${commit}, ${remote} and your own ${var.name} (field Variables) are inserted safely - a value never creates another command. Passwords belong in ${secret:name}: they are stored in Windows Credential Manager, never in a file, and are hidden in the output.
  • The output of the steps is under Step output of the last upload in the button menu; when a step fails, the notification has Show output too.

Templates

Save as template in the link dialog stores the settings (everything except the target) for other links. A link based on a template is:

  • Live - template changes apply to the link; a field with its own value has a dot, a click on it returns the template value. A template change that adds or changes steps, turns on deleting or removes protection applies only after you confirm it in the preview.
  • One-time - the template only fills in the link.

The More menu of the dialog: Export the link... / Import a link or template... (.mo-link.toml, without local paths and variables) and Save to the project (.magnumopus/deploy.toml in the repository, without passwords). A folder whose project has upload settings offers "The project has upload settings - Link" in the path bar; steps from the project run only after you approve them on the first upload (and again after they change in the repository).

Remove link... in the button menu, the folder context menu or the More menu of the link dialog. Nothing is deleted - the files in the folder and on the server stay; only the link settings, the memory of the last synchronization and watching the folder are forgotten. The confirmation can keep the settings as a template. The notification after removing has Undo.

Scripts

mo link upload <link> [--plan [--json]] [--yes] [--approve-all] [--max-delete=<n>] [--events]

Uploads the changes of a link without the window (console launcher mo.exe, waits and returns the code). --plan only prints the plan; --yes confirms what would otherwise need a preview (production, deleting, another branch). Items that need your approval one by one (a newer file on the server) are uploaded only with --approve-all as well; otherwise they are skipped and the code is 12.

In the running app the same upload with the window and notifications:

mo --cmd link.upload --wait          :: link of the active folder
mo --cmd link:shop --wait            :: link by name

--wait waits until the upload ends (including a preview or the first upload dialog) and returns its code. If the first upload opened by the script says the server matches a commit, the changes since that commit are uploaded right after it (with link.upload-selected only the selection) - with a preview when something is risky.

CodeMeaning
0uploaded, or nothing to upload
1failed (the reason is printed)
2the link has no first upload yet, the comparison opened in MagnumOpus Diff, or the link settings are invalid (for mo.exe also a wrong switch)
5no such link here (mo --cmd)
8cancelled (preview or first upload closed)
9linking is turned off (mo --cmd also when control from outside is turned off)
10needs confirmation - the plan is printed, run again with --yes (mo link upload)
12some items could not be uploaded
13too many deletes (--max-delete)
14a step before / after the upload failed

The command IDs are in the command reference.

Something wrong or missing? Open an issue