cf
Copy the contents of a folder to another folder on this server, or to a remote server, with rsync
- Command:
/go/cf - Category: Files
- Required option: A source folder and a destination folder
- Output:
Transferring files from <from> to <to>...for remote copies; nothing for local copies - Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
/go/cf ("copy files") copies everything inside a source folder into a destination folder. It uses rsync, so:
- files that are already up to date are skipped
- permissions, owners, and timestamps are kept
- symbolic links are copied as links
- data is compressed during a remote transfer
The destination can be another folder on this server, or a folder on a remote server.
Quick start
# Copy a folder's contents into another folder on this server
/go/cf /home/example.com/www /backup/example.com
# Copy a folder's contents to a remote server
/go/cf /home/example.com/www /home/example.com/www 203.0.113.10 'RemoteRootPassword'
Syntax
/go/cf <from> <to>
/go/cf <from> <to> <remote-server> <remote-password>
| Argument | Description |
|---|---|
<from> |
The source folder on this server. It must exist. |
<to> |
The destination folder. On this server, or on the remote server. |
<remote-server> |
The IP address or host name of the remote server. |
<remote-password> |
The root password of the remote server. |
A trailing / on either folder is added if you leave it out. The contents of <from> are copied into <to>, not the <from> folder itself.
Options
| Form | Arguments | What it does |
|---|---|---|
| Local copy | 2 | Copies the contents of <from> into <to> on this server. Both folders must already exist. |
| Remote copy | Exactly 4 | Copies the contents of <from> into <to> on the remote server, as root, over SSH. |
Rules
| Item | Rule |
|---|---|
| Paths for a local copy | Both must contain a /. Otherwise the command does nothing. |
| Remote copy arguments | Exactly four. The SSH port is always 22 (see Known issues). |
| Deleted files | Files removed from <from> are not removed from <to>. |
| Spaces in paths | Not supported. |
Output
| Message | Meaning |
|---|---|
Transferring files from <from>/ to <to>/... |
A remote copy started. |
<folder> Folder not exists. |
The source folder (or, for a local copy, the destination) does not exist. |
Neither form prints a list of files or a final message. A local copy is completely silent unless rsync reports an error. Each run adds a line to /var/log/go/cf.log (see Security).
Examples
# Local copy
/go/cf /home/example.com/www /backup/example.com
# Remote copy
/go/cf /var/skeleton /var/skeleton 203.0.113.10 'RemoteRootPassword'
# Check the result on the remote server
ssh root@203.0.113.10 'ls -la /var/skeleton'
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
<folder> Folder not exists. |
The source folder is missing. For a local copy, the destination folder is missing. | Check the paths, and create the destination folder for a local copy. |
| Nothing happens and nothing is printed | The paths have no /, or the number of arguments is not 2 or 4. |
Use full paths, and check the argument count. |
The remote copy fails with mkdir ... failed: No such file or directory |
The remote parent folder does not exist. The script does not create it (see Known issues). | Create the folder on the remote server first. |
mkdir: invalid option -- 'P' |
A mistake in the script's folder-creation step. | Create the folder yourself. The copy can still continue. |
Permission denied |
Wrong remote password, or root password login is off on the remote server. | See permitrootlogin. |
| Using a different SSH port does nothing, or copies locally | A fifth argument changes the form of the command. | See Known issues. |
| Files deleted at the source are still at the destination | rsync is run without --delete. |
Delete them at the destination yourself. |
| Files are not readable or owners are wrong after a local copy | The local copy does not use sudo. |
Run the command as root. |
Details
How it works
- Logs the run to
/var/log/go/cf.log. - With exactly 4 arguments, runs the remote copy:
- Checks the source folder, and adds a trailing
/to both folders. - Tries to create the destination folder on the remote server.
- Prints
Transferring files from ... to .... - Runs
rsync -azlhthroughsshpassandsshon port22, with host key checking turned off.
- Checks the source folder, and adds a trailing
- Otherwise, if both of the first two arguments contain a
/, runs the local copy: checks that both folders exist, adds trailing slashes, and runsrsync -azlh.
rsync flags
| Flag | Meaning |
|---|---|
-a |
Archive: keep permissions, owners, groups, timestamps, and links. |
-z |
Compress during transfer. |
-l |
Copy symbolic links as links. |
-h |
Human-readable numbers. |
Security
[!WARNING]
- The whole command line is written to
/var/log/go/cf.log, so the remote password is saved there in plain text. Remove the line after a remote copy.- The password on the command line can be seen in the process list and is saved in your shell history.
- SSH host key checking is turned off and known hosts are not saved, so the identity of the remote server is not verified.
Known issues
- Custom port does not work. The script reads a port from the fifth argument, but the remote copy only runs when there are exactly four arguments. With five arguments, the command takes the local-copy path instead. If the destination folder also exists on this server, files are copied locally into it.
- Remote folder is not created. The script runs
mkdir -P, which is not a valid option (-pis correct).rsynccreates only the last level of the destination path, so the remote parent folders must already exist. - Exit status. A remote copy always ends with status
1, including on success. Do not use it to detect errors. - The remote copy connects with the root account of the remote server and needs
rsyncinstalled there.
See also
| Command | Description |
|---|---|
fsync |
Copy a directory from your local server to a remote server |
copywww |
Copy the www directory from one domain to another |
copy |
Copy a GoAdmio site from one server to another |
cb |
Copy GoAdmio backups from the local server to a remote server |
serversync |
Back up and migrate a GoAdmio server with all configurations |
permitrootlogin |
Allow root SSH login from a specific IP |