Script to transfer backup from Hosting server to my synology server one account at a time.

Hi Linux/Unix pros,

I'm need to create a script and here's what it need to do:

  1. SFTP to my Hosting Server (Linux) sftp user@hostingserver.com
  2. Backup website accounts 1 at a time (This is due to server space). This is the command to backup each cPanel account:
/usr/local/cpanel/scripts/pkgacct sentiments /home
  1. Pull the backup to source server (Synology) and delete it in the hosting server after transfer.
  2. Repeat step 1-3 until all accounts has been transferred successfully.

The script will be running from Task Scheduler in synology server.
Also I wonder if port forwarding is needed to do this? I'm hoping not as my internet provider does not allow this.

What I dont understand is where is your Synology?
If it is at home, unless you pay to have a fix IP your provider will give you a dynamic and your lan at home is a private one
So if it is the case it will be a little bit more complex than what you described...

Yeap it is at home. For static IP or port forwarding my ISP require me to opt for Business internet which is very expensive. Since I'm reaching out to the hosting server I was under the impression that I will not need the port forwarding. As a last resort I can still have the port forwarding arranged if required.