I have a host where an application creates model directories/files. I want to tar up those files and send it over to another host for DR backup.
So far I have the following:
sudo tar -zcvf - /mnt/nfsshared | ssh [email protected]<ip-address> "cat > /data/models/models_$(date +\%Y-\%m-\%d).tar.gz" > /dev/null 2>&1
This command will tar up all directories and files in /mnt/nfsshared and create the tarball on the remote host under /data/models/ However, I want to exclude the the /mnt/nfsshared/ parent directories and just tar up the directories/files in the /nfsshared directory.
I know I could cd to /mnt/nfshared and tar up all files.
I can also do this command
sudo -C /mnt/nfsshared -zcvf | ssh [email protected]<ip-address> "cat > /data/models/models_$(date +\%Y-\%m-\%d).tar.gz" > /dev/null 2>&1
which would only tar up directories/files under nfsshared. However, what argument would I pass to the command: -zcvf I can't use a tarball name since the tarball gets created on the remote host.
Within /mnt/nfsshared/ I have multiple directories containing additional subdirectories and files.
/mnt/nfsshared/model1/files /model2/files /model3/submodel1/files /submodel2/files /submodel3/files /model4/submodel1/files I want only to tar up the model, submodel directories and the files I want to exclude the /mnt/nfsshared directories Cheers, Roland