Sitecopy is a tool for copying locally stored sites to a remote server (via FTP or WebDAV). It helps you keep the remote location in sync with your local copy by uploading modified local files and deleting remote files that are deleted on the local computer. This tutorial shows you how to manage your remote location from your local Ubuntu 18.04 desktop with Sitecopy.
1 Preliminary Note
I use the username for on my local Ubuntu desktop (I am logged into my local Linux desktop as a user – do not log in as root). The files for the remote page example.com are stored in the directory /home/t//sites/example.com/ on the local computer. The remote document root is /var/www/example.com/web/ .
You can use sitecopy with FTP and WebDAV, so you should have either an FTP or a WebDAV account on the remote server. I use the FTP username by default to and the password howtoforge here.
The remote location I use for these examples was created with ISPConfig. But all websites where you have FTP or WebDAV access will work.
2 Install sitecopy
Sitecopy can be installed on the local desktop as follows (we need root privileges, therefore we use sudo ):
sudo apt-get -y install sitecopy  You should now look at sitecopy's man page to familiarize yourself with its options:
3 Configure sitecopy
Go to your home directory on the local desktop ...
cd ~  ... and create directory .sitecopy with permissions of 700 (sitecopy uses that directory to store file information):
mkdir -m 700 .sitecopy
Then create the sitecopy configuration file .sitecopyrc :
chmod 600 .sitecopyrc
Open file ...
... and fill in the site configuration example .com . Here are two examples, one for FTP ...site example.com server example.com username by default password howtoforge local /home/till/sites/example.com/ remote control ~ / web / exclude * .back excluded * *
... and one for WebDAV:site example.com server example.com protocol webdav username by default password howtoforge local /home/till/sites/example.com/ remote /var/www/example.com/web/ exclude * .back Exclude * *
(You can define a penalty for each site you want to manage with sitecopy.)
The directive must be followed by a name on the site - you can freely select one, e.g. example.com or mysite . This name will be used later in the sitecopy commands. The following configuration options that belong to that site must be revoked!
Most of the following configuration options are self-explanatory. The default protocol is FTP; if you want to use WebDAV, enter protocol webdav . The local directive contains the local path for the site copy, the remote control contains the path to the site on the remote server - it can be absolute or relative. If your user is hacked (as is usually the case with FTP users), you should use a relative path (such as ~ / or ~ / web ). Otherwise, use an absolute path.
exclude rows are optional, they are here only to show how you can exclude files from sitecopy maintenance.
You can read more about sitecopy configuration on its man page:
4 First use
Before using sitecopy for the first time, you must determine which of the following three scenarios matches your situation:
- Existing remote location and local copy, both synchronized.
- Existing remote location, no local copy.
- New remote location, existing local copy.
4.1 Existing remote location and local copy, both synchronized
If both the remote location and the local copy exist and are in sync, run
sitecopy --catchup example.com
to make sitecopy believe that the local the site is exactly the same as the remote copy. Replace example.com with the name of the site you are using in the .sitecopyrc file.
[email protected]: ~ $ sitecopy --catchup example.com
sitecopy: Catching up site "example.com" (at example.com in ~ / web /)
sitecopy: All files and directories are marked as updated at a distance.
4.2 Existing remote site, no local copy
If you do not have a local copy of the existing remote site, run
sitecopy - download example.com
first so that sitecopy retrieves the list of files from the remote server (replace example.com with the name of the site you use in the .sitecopyrc file):
[email protected]: ~ $ sitecopy - download example.com
sitecopy: Download the site "example. com "(for example.com in ~ / web /)
File: error / 503.html - size 1906
File: error / 502.html - size 1881
File: error / 500.html - size 1851
File: error / 405.html - size 1810
File: error / 404.html - size 1806
File: error / 403.html - size 1809
File: error / 401. html - size 1806
File: error / 400.html - size 1792
File: stats /. htaccess - size 128
File: robots.txt - size 14
File: index.html - size 1861
File: favicon.ico - size 7358
File: .htaccess - size 26
Catalog: error /
Catalog: statistics /
sitecopy: Download completed successfully.
sitecopy --synch example.com
to update the local site from the remote copy.  sitecopy: Sync the site & # 39; example.com & # 39; (for example.com in ~ / web /)
Create Error /: done.
Create Statistics /: done.
Download Error / 503.html: [.] done.
Download Error / 502.html: [.] done.
Download Error / 500.html: [.] done.
Download Error / 405.html: [.] done.
Download Error / 404.html: [.] done.
Download Error / 403.html: [.] done.
Download Error / 401.html: [.] done.
Download Error / 400.html: [.] done.
Download Statistics / .htaccess: [.] done.
Robots.txt download: [.] done.
Downloading index.html: [.] done.
Download favicon.ico: [.] done.
Download .htaccess: [.] done.
sitecopy: The synchronization has been successfully completed.
4.3 New remote site, existing local copy
If the local copy exists, but you have an empty remote site, run
sitecopy --init example.com
first to initialize the site. Replace example.com with the name of the site you are using in the .sitecopyrc file.
[email protected]: ~ $ sitecopy --init example.com
sitecopy: Initiate site "example.com" (at example.com in ~ / web /)
sitecopy: All files and directories are marked as NOT updated at a distance.
sitecopy - update example.com  to upload the local copy to the remote site:
[email protected]: ~ $ sitecopy - update example.com
sitecopy: Update site "example. com "(at example.com in ~ / web /)
Create Statistics /: done.
Create data /: done.
Create Error /: done.
Upload Statistics / .htaccess: [.] done.
Upload data / index.html: [.] done.
Upload Error / 403.html: [.] done.
Upload error / 401.html: [.] done.
Upload Error / 404.html: [.] done.
Upload Error / 503.html: [.] done.
Upload error / 400.html: [.] done.
Upload error / 502.html: [.] done.
Upload Error / 405.html: [.] done.
Upload error / 500.html: [.] done.
Uploading index.html: [.] done.
Uploading robots.txt: [.] done.
Uploading .htaccess: [.] done.
Uploading favicon.ico: [.] done.
sitecopy: The update was successfully completed.
Next, using sitecopy is really easy. You can work with your local copy and update, create and delete files. A first, but optional step is to run
to find out which files have changed locally (replace example.com with the name of site you use in .sitecopyrc file):
[email protected]: ~ $ sitecopy example.com
sitecopy: Displays changes to the "example.com" site (at example.com in ~ / web / )
* These items have been added since the last update:
sitecopy: Remote location needs updating (1 item to update).
To synchronize your remote page with your local copy (i.e. upload new and changed files to the remote server and delete files on the remote server that have been deleted locally), you simply run
sitecopy --update example.com : ~ $ sitecopy - update example. com
sitecopy: Updating the website "example.com" (at example.com in ~ / web /)
Uploading information.php:  completed.
sitecopy: Update completed successfully.
T hat is it! Have fun with sitecopy!