1

I have ubuntu 14 headless server and I have data continuously updating on it. I wish to take back up every 15 mins to remote host. I don't have much access to remote host and I just have to drop files on it. I have successfully established FTP bash script which runs every 15 mins. Now I dont same files to get uploaded on remote host. Once file is upload,I don't want same file to upload on remote host. I have written bash script for FTP upload but I don't know what to do with this repetition upload.

there is something

file /path/to/upload -maxdepth 1 -mtime 0.04 > path/to/filelist.txt

But this is of no use and my files repeatedly keeps uploading same files again and again over 15 mins (I have set up cronjob after 15 mins)

Please help me,I am a Linux newbie,little illustration will be useful.

  • 1
    Don't you mean _find_ /path/to/upload -maxdepth 1 -mtime 0.04 > path/to/filelist.txt? – nyov Aug 29 at 23:58
  • It's not clear to me, if you are uploading to the Linux server or from the Linux server. If "to", what is your local system? – Martin Prikryl Aug 30 at 5:47
  • I am uploading from Linux server to FTP accessible host (I don't know the nature of machine which is remote and I can't access folders or any such thing,I am suppose to just upload using FTP to my clients FTP accessible host and that's it) – Merlincool Aug 31 at 4:49
0

If you can, use rsync instead of ftp. It was built for this and is much more efficient.

If you have to use ftp, find should work for this. Try this format:

find /path/to/upload -maxdepth 1 -cmin -15

where -15 means less than 15 minutes ago. +15 would mean older than, and 15 exactly 15 minutes ago.

Alternatively, you can use a reference file or timestamp (which is supported on newer find:

find /path/to/upload -maxdepth 1 -newerct $(date -Iseconds -d '15 minutes ago')

where -newerct is a form of -newerXY, using the status change time of the reference (c) where the reference is a plain timestring (t) instead of a referenced file, and is provided by
date -Iseconds -d '15 minutes ago'.


You might want to be careful with taking backups too often, depending on your use-case; or you could overwrite good backups with bad data before you noticed there was something bad with it.
Or add multiple incremental backups to the full backup, so you have the option to roll back to different points in time.

  • I get this as output error - "find: I cannot figure out how to interpret `2019-08-31T00:38:45-0400' as a date or time" (without double quotes) – Merlincool Aug 31 at 4:56
  • This is my script#!/bin/sh DIR="/path/to/upload/ USER="******" PASS="******" SERVER="ftp.server.ip" DIR1="/path/to/save/TXT/filelist.txt" cd $DIR #find $DIR -maxdepth 2 -mmin -30 > $DIR1 sleep 5 #FILE=ls -t *.mkv| head -1 FILE="*" ftp -inv $SERVER <<EOF user $USER $PASS put $FILE quit EOF – Merlincool Aug 31 at 5:08
  • @Merlincool, your time-string works here, using find (GNU findutils) 4.6.0.225. Try with some date format variations then: find . -maxdepth 1 -newermt "$(date --rfc-3339=seconds -d '15 minutes ago')", maybe drop the timezone: find . -maxdepth 1 -newermt "$(date -d '15 minutes ago' '+%F %T')". – nyov Aug 31 at 5:22
  • Thank you very much I am truly sorry to understand this syntax. My GNU IS 2.2.6 on Ubuntu 14, so which will be correct time syntax I want to order my Ubuntu folder to check every 15 mins if any file was newly added to folder, and if it has then please upload via FTP session and also while checking please make sure you don't re-upload the already uploaded file on remote server. If my syntax is wrong,I would like to know the exact correct syntax that will help me. – Merlincool Aug 31 at 9:52
  • @Merlincool, I don't know which syntax your version of find supports, you'll have to check the manual pages yourself, or test around with the date strings I provided. man date explains how they are formatted. – nyov Aug 31 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.