In this article, we will be working with the "External FTP Storage" service.
FTP Storage Activation
This service is available in the corresponding Billing section. Select the "Dynamic Plan."
Specify the desired storage capacity (up to 3.5TB), for example, 50GB, then add the plan to your cart and make the payment.
A few seconds after the payment, the service will be activated and visible in a special section.
To get the information needed for working with it, select the service and click on the "Instructions" button.
A new tab will open with all the necessary data for your work.
Test Upload with lftp
Now let's move on to our main server, from which we will be uploading files to the FTP storage. We will need the article "Working with FTP Storage."
We will need lftp. To install the utility on Debian/Ubuntu, use the following command:
sudo apt-get -y install lftp
Great! Let's try to upload a test file, but first, let's create it using the touch command.
Now, let's enter the command to upload the file:
lftp ftp://login:firstname.lastname@example.org:21 -e "set ftp:ssl-allow no; put -O / file; quit"
login — the storage username.
pass — the storage password.
backup.s1.fsn.spacecore.pro — the upload server (do not change this).
/ — the directory where the file will be uploaded in the storage.
file — the name of the file to be uploaded.
For our service, use this command:
lftp ftp://spacecore35176:KDAcfR4p1tyz@backup.s1.fsn.spacecore.pro:21 -e "set ftp:ssl-allow no; put -O / spacecore; quit"
After entering the command, it will connect to the remote server and upload the file (the upload time depends on the size of the file being transferred and the network speed). Once the process is complete, you can see your file by connecting to the storage via FTP.
But the question remains: "How can we automate this process?"
First, let's create a script that will perform all the necessary actions when executed. Create a file and open it with the command:
Where backup.sh is the name of the file.
Create a short script with our upload command.
lftp ftp://spacecore35176:KDAcfR4p1tyz@backup.s1.fsn.spacecore.pro:21 -e "set ftp:ssl-allow no; put -O /backups backup.tar.gz; quit"
Where #!/bin/bash is the necessary line indicating that this is a shell script.
/backups — a new directory for storing uploaded files in the storage (which needs to be created on the FTP server itself).
backup.tar.gz — the new name of the file to be uploaded.
Optionally, before uploading the file, you can add commands to archive important data that needs to be saved on the remote server.
Save the file with our script using Ctrl + X -> y.
Now, let's try to upload the file using the shell script (in our case, we are uploading the backup.tar.gz archive, so let's create it first). Then use our script.
The upload has started. Wait for the process to complete.
The script is working! Our data archive has been successfully uploaded to the remote FTP server.
Automation via CRONTAB
You can find more detailed information on working with CRON in public articles on various websites.
Use the following command to open the CRON configuration.
It's empty at the moment. Developer information on automation setup is provided as comments.
Minute Hour Day Month Weekday /path/to/file
Add this line to schedule our upload script to run every day at 00:00 server time.
0 0 * * * /root/backup.sh
Where /root/backup.sh is the path to the executable file.
Excellent work! We have created our own script for uploading backup files and learned how to automate this task using CRONTAB.