crontab a bash script that is copying certain files

0

First I would like to say that I am terrible with scripting so this has been a true challenge for me. Any input would be great!

I would like to automate an sftp transfer every 24h. If I am lucky in the near future, I might be able to mount this share instead or at least have an ssh connection to use rsync or scp.

Ubuntu 10.04 In /res/output/ I will have new directories created all the time (with a counter added to the directory name) such as: /res/output/my_output_17/.pdf /res/output/my_output_17/addon/addon_1/.db (the directories "addon/addon_1/" always have that name so only the my_output_* will change name as well as the 2 files of interest. These should be dumped to a remote sftp directory, where we should save them int my_output_* directory that the script needs to create as well.

How can I do this? I want to make sure I only copy the non-transferred files. I would assume I need to populate some "db file" and make sure those files are skipped next time the script is running?

Thanks

Mackis5

Posted 2013-11-14T14:00:17.807

Reputation: 1

Answers

0

I would use rsync it can copy over what is absent/different on remote.

eg rsync -av /res/output user@remotehost:/where/you/want/them

add that line to your crontab

rsync will need to login to your remote host, so you must also fix this if that doesn't work for you now. (can you ssh into your remote host without needing to supply a password ? are the public/private keys setup ?)

X Tian

Posted 2013-11-14T14:00:17.807

Reputation: 182

Since the OP mentions that his experience with scripting is weak, I think he expects a bit more detailled answer. This should be a comment maybe ? – mveroone – 2013-11-14T14:48:59.717

My Linux skill is strong, so don't worry:) Thanks for the suggestion. Since I am only interested in 2 files, one per directory, and not the other 100's of files and folders, so unfortunately this will not work. I have been using rsnapshot in the passed, but I feel it is an overkill, but maybe that is the way forward. – Mackis5 – 2013-11-15T07:37:31.027

There's always the this option, --include=PATTERN – X Tian – 2013-11-15T14:32:05.773