Backup staging files before deployment
Use this skill with /deploy-files-staging when the user provides the exact
repository-relative files that will be overwritten on staging and wants a
local backup first.
This skill downloads files only. It never uploads, deletes, or modifies remote
staging files, and it never changes repository files.
Required setup
The first use must configure the local backup directory. Do not ask for it
again after it has been saved:
. "$HOME\.copilot\skills\backup-staging-files\StagingBackupSettings.ps1"
$backupRoot = Get-StagingBackupRoot
If $backupRoot is empty, ask the user where backups should be saved, then
persist the answer outside the repository:
& "$HOME\.copilot\skills\backup-staging-files\Set-StagingBackupRoot.ps1" `
-BackupRoot '<user-selected absolute directory>'
The setting is stored at:
%LOCALAPPDATA%\GitHub Copilot\backup-staging-files\settings.json
The backup directory must be outside the repository. If the user explicitly
requests a different backup location later, save the new location before
continuing.
The staging remote root is shared with /deploy-files-staging. It must already
be saved by that skill. Do not create a second remote-root setting or ask for a
second remote-root value unless the deploy skill has not been configured.
Backup workflow
Take the file list from the user's additional context or from the exact
deployment preview. Do not infer a different list from git diff.
Pass the actual deployable paths, not source paths that will only produce a
DLL. Paths must be under Tireweb Sites\Web; use the staged DLL paths when
the deployment includes rebuilt projects.
Run a dry run before downloading:
$backupRunName = 'staging-' + [DateTime]::UtcNow.ToString('yyyyMMdd-HHmmssfff')
& "$HOME\.copilot\skills\backup-staging-files\Backup-StagingFiles.ps1" `
-RepositoryRoot (Get-Location).Path `
-IncludePaths $deploymentPaths `
-BackupRunName $backupRunName `
-WhatIf
The dry run opens the read-only SFTP connection, preflights every remote
file, and then shows the complete remote-to-local mapping, the persisted
backup root, and the proposed timestamped run directory. It creates no run
directory, manifest, or downloaded file. The proposed directory is not
reserved: if it becomes occupied before execution, the real run allocates
the next available -1, -2, and so on suffix. Treat the directory and
manifest reported after the real run as authoritative.
In standard mode, ask for explicit confirmation after a successful dry run.
If the user explicitly requested autopilot, proceed after the successful
dry run without a second confirmation. Run the same command without
-WhatIf, without changing the file list or run name, and with
-Confirm:$false so the skill's confirmation is not duplicated:
& "$HOME\.copilot\skills\backup-staging-files\Backup-StagingFiles.ps1" `
-RepositoryRoot (Get-Location).Path `
-IncludePaths $deploymentPaths `
-BackupRunName $backupRunName `
-Confirm:$false
Direct script callers retain PowerShell's normal high-impact confirmation
behavior when -Confirm:$false is not supplied.
Report the created backup directory, manifest path, every backed-up file,
remote path, local path, and verified byte size. Do not display file
contents.
Only after the backup succeeds should /deploy-files-staging be allowed to
upload the same exact file list.
Script behavior
Backup-StagingFiles.ps1:
- Reuses the deploy skill's saved remote root, Windows Credential Manager
credential, pinned SFTP host key, and bundled WinSCP library.
- Rejects traversal, absolute repository paths, missing local paths, paths
outside
Tireweb Sites\Web, and sensitive/secret files.
- Performs a remote preflight for every requested file before downloading.
- Creates a new timestamped run directory under the configured backup root.
- Preserves the remote
Tireweb Sites\Web-relative path beneath that run
directory.
- Writes
manifest.json with the remote/local mappings, status, timestamps, and
verified sizes.
- Verifies every downloaded file against the remote size.
- Leaves a failed run manifest marked
failed if a transfer stops partway
through; it does not delete partial backups.
The skill depends on the installed deploy-files-staging skill for SFTP
authentication and WinSCP. It intentionally contains no credentials,
certificates, or third-party binaries so it can be published safely to GitHub.
Safety requirements
- Never request, print, store, or pass the SFTP password in chat or source
control.
- Never read or modify FileZilla's
sites.xml.
- Never delete remote files.
- Never silently continue after a missing remote file or size mismatch.
- Never deploy automatically; backup and deployment remain separate steps.
1---2name: backup-staging-files3description: Back up an explicit list of Ezytire staging files to a persisted local directory before deployment, reusing deploy-files-staging SFTP settings and credentials.4---56# Backup staging files before deployment78Use this skill with `/deploy-files-staging` when the user provides the exact9repository-relative files that will be overwritten on staging and wants a10local backup first.1112This skill downloads files only. It never uploads, deletes, or modifies remote13staging files, and it never changes repository files.1415## Required setup1617The first use must configure the local backup directory. Do not ask for it18again after it has been saved:1920```powershell21. "$HOME\.copilot\skills\backup-staging-files\StagingBackupSettings.ps1"22$backupRoot = Get-StagingBackupRoot23```2425If `$backupRoot` is empty, ask the user where backups should be saved, then26persist the answer outside the repository:2728```powershell29& "$HOME\.copilot\skills\backup-staging-files\Set-StagingBackupRoot.ps1" `30 -BackupRoot '<user-selected absolute directory>'31```3233The setting is stored at:3435```text36%LOCALAPPDATA%\GitHub Copilot\backup-staging-files\settings.json37```3839The backup directory must be outside the repository. If the user explicitly40requests a different backup location later, save the new location before41continuing.4243The staging remote root is shared with `/deploy-files-staging`. It must already44be saved by that skill. Do not create a second remote-root setting or ask for a45second remote-root value unless the deploy skill has not been configured.4647## Backup workflow48491. Take the file list from the user's additional context or from the exact50 deployment preview. Do not infer a different list from `git diff`.512. Pass the actual deployable paths, not source paths that will only produce a52 DLL. Paths must be under `Tireweb Sites\Web`; use the staged DLL paths when53 the deployment includes rebuilt projects.543. Run a dry run before downloading:5556 ```powershell57 $backupRunName = 'staging-' + [DateTime]::UtcNow.ToString('yyyyMMdd-HHmmssfff')5859 & "$HOME\.copilot\skills\backup-staging-files\Backup-StagingFiles.ps1" `60 -RepositoryRoot (Get-Location).Path `61 -IncludePaths $deploymentPaths `62 -BackupRunName $backupRunName `63 -WhatIf64 ```65664. The dry run opens the read-only SFTP connection, preflights every remote67 file, and then shows the complete remote-to-local mapping, the persisted68 backup root, and the proposed timestamped run directory. It creates no run69 directory, manifest, or downloaded file. The proposed directory is not70 reserved: if it becomes occupied before execution, the real run allocates71 the next available `-1`, `-2`, and so on suffix. Treat the directory and72 manifest reported after the real run as authoritative.735. In standard mode, ask for explicit confirmation after a successful dry run.74 If the user explicitly requested `autopilot`, proceed after the successful75 dry run without a second confirmation. Run the same command without76 `-WhatIf`, without changing the file list or run name, and with77 `-Confirm:$false` so the skill's confirmation is not duplicated:7879 ```powershell80 & "$HOME\.copilot\skills\backup-staging-files\Backup-StagingFiles.ps1" `81 -RepositoryRoot (Get-Location).Path `82 -IncludePaths $deploymentPaths `83 -BackupRunName $backupRunName `84 -Confirm:$false85 ```8687 Direct script callers retain PowerShell's normal high-impact confirmation88 behavior when `-Confirm:$false` is not supplied.896. Report the created backup directory, manifest path, every backed-up file,90 remote path, local path, and verified byte size. Do not display file91 contents.927. Only after the backup succeeds should `/deploy-files-staging` be allowed to93 upload the same exact file list.9495## Script behavior9697`Backup-StagingFiles.ps1`:9899- Reuses the deploy skill's saved remote root, Windows Credential Manager100 credential, pinned SFTP host key, and bundled WinSCP library.101- Rejects traversal, absolute repository paths, missing local paths, paths102 outside `Tireweb Sites\Web`, and sensitive/secret files.103- Performs a remote preflight for every requested file before downloading.104- Creates a new timestamped run directory under the configured backup root.105- Preserves the remote `Tireweb Sites\Web`-relative path beneath that run106 directory.107- Writes `manifest.json` with the remote/local mappings, status, timestamps, and108 verified sizes.109- Verifies every downloaded file against the remote size.110- Leaves a failed run manifest marked `failed` if a transfer stops partway111 through; it does not delete partial backups.112113The skill depends on the installed `deploy-files-staging` skill for SFTP114authentication and WinSCP. It intentionally contains no credentials,115certificates, or third-party binaries so it can be published safely to GitHub.116117## Safety requirements118119- Never request, print, store, or pass the SFTP password in chat or source120 control.121- Never read or modify FileZilla's `sites.xml`.122- Never delete remote files.123- Never silently continue after a missing remote file or size mismatch.124- Never deploy automatically; backup and deployment remain separate steps.