Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Automated backup of files

  1. Oct 6, 2007 #1
    I want to write a script that will automatically backup my documents to a remote computer. I have a lot (~500 MB) of files, so I only want the files to be backed up when a newer version exists.

    Short version of the question: how do I read a single line from a text file using bash?

    Long version of the question:
    Here is the plan for the script....

    #!/bin/bash
    ssh remoteComputer # connect to remote comp
    find ~/Documents * > files.txt #find all files in documents and write to files.txt
    line=1
    fileLength = (number of lines if files.txt)
    while [line -lte fileLength]
    do
    (put filename at the lineth line to the string fileName)
    if fileName -nt remoteComputer:~/Documents/fileName
    #go through all files and
    #check to see if remoteComputer has the
    #latest version of this file already
    scp line to remoteComputer
    #if so, update file
    fi
    line=$[$line+1]
    done
    exit #leave ssh session

    The exact implementation is what I need help on. If I could read files.txt line by line this would be very easy, but I can't figure it out!
     
  2. jcsd
  3. Oct 6, 2007 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    You should look at rsync, it not only does this but can copy just the parts of files that have changed.
     
  4. Oct 6, 2007 #3
    That's just too easy! Thanks mgb_phys!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Automated backup of files
  1. PDF files (Replies: 3)

  2. Data backup software (Replies: 1)

  3. File output (Replies: 4)

Loading...