I am new to Ubuntu but I have to do a small script which backups all my files on my server to my local computer. I made a script on my server called backupscript and put the following command
zip -r Backupfile /home/ubuntu
sudo scp -P 22 /home/ubuntu/Backupfile.zip user@ipaddress:/home/user
I save it and execute this script from terminal ./backupscript
But then I get a message ssh: connection to host ipaddress port 22: connection lost.
I opened port 22 in my host computer using this
sudo ufw allow 22
but still unable to scp the file from my server to host computer.
-v
immediately afterscp
, rerun the command and edit your question ti include the results. This should give some diagnostic information that may help solve the issue – Nick Sillito Jun 04 '17 at 07:32sudo
at the start of the scp line. Whilst I dont think that its a problem, it would help diagnostics if you could rerun with out thesudo
command – Nick Sillito Jun 04 '17 at 07:36sudo scp -P 22 user@remote-server:/home/ubuntu/Backupfile.zip /home/user
. So you can create cronjob on the remote server that will create the backup, and cronjob on the local machine that will download the backup. – pa4080 Jun 04 '17 at 09:10