Hi,
I need to write an bash script which works like it can copy files from remote machine through ssh to the server where script is running in zip format with the structure i want. I don't want to get absolute path in zip archive. Please let me know how it can be possible.
ssh source-ip-address zip backup.zip /home/dir1/test.txt /home/dir1/test/test2.txt
# /home/dir1/test2/txt is the source.
unzip -l backup.zip > list.txt
`cat list.txt`
# list.txt contains /home/dir1/test.txt /home/dir1/test/test2.txt
By default zip store absolute paths. While i don't want to store /home/dir1 & /home/dir2/ in zip archive. I need zip file in following format.
test.txt
test/test2.txt
I know it is possible if i can change working directory when creating zip but as i am creating zip through remote machine, don't know how to change working directory. like it doesn't works
ssh source-ip-address cd /home/dir1
ssh source-ip-address zip backup.zip test.txt test/test2.txt
Or is there anyway that i can zip the files from root path means not to include common path in archive i.e. /home/dir1
Thanks,