0

I want to remote directory to local directory.script works properly but I have face some issue every time SCP update all files. My use case only updated file is copy the remote directory to local directory. if any bash gem helps appreciated your efforts. The source code is attachedenter image description here.

  • Please rephrase you question as I don't get what you are saying and don't images but copy and paste the the texts from the terminal – George Udosen Oct 19 '20 at 07:55
  • I've suggested an edit that takes care of the above. – Artur Meinild Oct 19 '20 at 08:02
  • Please elaborate on the following: You make a local directory with the current date. When you want to update files from remote to local, is it "per day", or should it compare today with the files from yesterday, and only copy updated? – Artur Meinild Oct 19 '20 at 08:24
  • Yes, I wanted the only update file for the last day backup Date directory. Compare or something else solution no issue I want the only updated file, not every file override. The date is just the directory name. – Farhan Hameed Oct 19 '20 at 09:16
  • @ArturMeinild you are right current date the just local directory name. the second question yes, compare file only update file is copy update. – Farhan Hameed Oct 19 '20 at 09:19
  • If the directory name didn't change, you could use rsync. If you want a new directory every day, you have compare the files from remote and yesterday first. – Artur Meinild Oct 19 '20 at 09:22
  • #!/bin/bash #-- start config

    Local Directory for backups. A date-specific folder is created under this directory for the files.

    LD=/home/ec2-user/newFolder

    Remote Directory to retrieve. Files are retrieved recursively starting here. Hidden files are included.

    Must be full path, don't use ~ shortcut.

    RD=/home/ec2-user/new

    Path to SSH ID file (private key)

    ID=~/.ssh/id_rsa

    DATE=$(date '+%Y-%m-%d %H:%M:%S')

    USERname to login as

    USER=user-name

    HOST to login to

    HOST=host-name #--- end config

    BD="$LD/$DATE" mkdir $BD scp -ri $ID $USER@$HOST:$RD $BD

    – Farhan Hameed Oct 19 '20 at 09:22
  • @ArturMeinild kindly provide the compare bash script. – Farhan Hameed Oct 19 '20 at 09:24
  • I was hoping someone else could do that, I have my hands full right now, sorry. – Artur Meinild Oct 19 '20 at 09:25

0 Answers0