I have written the following script. It creates a new directory formatted like this Year,Month,Day. What it suppose to do is copy a file to the newly created directory, the script makes the directory on the remote server, but copies the file to the directory not the subdirectory which is suppose to be the 2017-08-18, and so on.
[root@hostname ~]# cat ontape.sh #!/bin/bash # sshpass -p 'PASSWORD' ssh root@hostname mkdir -p /home/mybackup/ontape/$(date +%Y-%m-%d) sshpass -p 'PASSWORD' ssh root@hostname mkdir -p /mybackup/ontape_tmp_backup/$(date +%Y-%m-%d) for server in $(cat servers.txt) do sshpass -p 'PASSWORD' scp /dbbackup/backupdb/ontape/fullsize/* $server done
Also, the /root/servers.txt file has the following code.
[root@hostname ~]# cat servers.txt root@hostname:/mybackup/ontape_tmp_backup root@hostname:/home/mybackup/ontape