Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
This may be an odd request, or it may be a common thing-- no idea! Anyone know of a way to do incremental backups of a single file? In other ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    10

    How To Do Incremental Backups of an Individual File?


    This may be an odd request, or it may be a common thing-- no idea!

    Anyone know of a way to do incremental backups of a single file?

    In other words, back up changed parts of the file, rather than backing up the entire file every time.

    Can it be done with rsync or fwbackup or anything else?

    thanks

  2. #2
    Just Joined!
    Join Date
    May 2012
    Posts
    9
    Rsync will perform incremental backups by default. This means that it will not recopy all of the files every single time a backup is performed. Instead, only the files that have been newly created or modified since the last backup will be copied

    Another option is through SVN (Subversion) . Each time a change is made to the file it is committed to the SVN. If u want to test the fix that has been committed You can checkout the SVN on your local system in which latest changes will be noticed
    Last edited by oz; 05-26-2012 at 05:43 PM. Reason: signature removal

  3. #3
    Just Joined!
    Join Date
    Aug 2011
    Posts
    10
    Hi

    Afraid you're misunderstanding. I'm not talking about multiple files. Just one, single, individual file. See?

    Thanks for reply!

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,286
    Hi.

    K & P produced a suite of small tools to collect the history of a file. As with most versioning tools, they rely on diff to produce the differences.

    I use the book: Amazon.com: Unix Programming Environment (Prentice-Hall Software Series) (978013937681: Brian W. Kernighan, Rob Pike: Books , but it may be available elsewhere, possibly at Google for searching.

    The code I mentioned is on page 167, put and get.

    Personally, I find that the RCS commands ci and co are easy to script and the RCS repository (history directory) can be localized to the current directory. The bzr utility can also use a local repository.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Just Joined!
    Join Date
    Aug 2011
    Posts
    10
    This may be beyond me, but I'll explore it.

    Thanks.

  6. #6
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,286
    Hi.
    Quote Originally Posted by johnywhy View Post
    This may be beyond me, but I'll explore it.
    The saving script about 30 lines long, and will require its companion get, as well as script overwrite. If nothing else, you'll be able to see some of the power of shell scripting, as well as a few techniques.

    The scripts can also be used as black boxes without knowing much about how they work.

    I don't see how this task could be made much smaller, although perhaps a bare-bones RCS approach might work.

    Good luck ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  7. #7
    Just Joined!
    Join Date
    Aug 2011
    Posts
    10
    Many thanks. Just ordered the book. I expect not to understand it without hours of struggle and research and kind help from others.

  8. #8
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,286
    Hi.

    While you are waiting for the arrival of the book, you can look at this demonstration of the RCS approach. This script initializes the environment by removing the test file, hi.txt, and the associated history (version) file, hi.txt,v. It steps through by displaying the file in several stages, and shows the files that remain after the steps, culminating in a display of the log of the actions to the file.
    Code:
    #!/usr/bin/env bash
    
    # @(#) s1	Demonstrate RCS ci and co for keeping history of single file.
    
    pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
    pl() { pe;pe "-----" ;pe "$*"; }
    db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
    db() { : ; }
    C=$HOME/bin/context && [ -f $C ] && $C sed ci co
    
    FILE=hi.txt
    
    # Remove data file and history file.
    rm -f $FILE ${FILE},v
    
    pl " Current files before operations:"
    ls -lgG
    
    cat > $FILE <<EOF
    one
    two
    three
    EOF
    
    pl " Data file $FILE:"
    head $FILE
    
    pl " Current files before checkin:"
    ls -lgG
    
    pl " Checking in file $FILE (simulated comment supply):"
    ci $FILE <<<" First version."
    
    pl " Current files after  checkin:"
    ls -lgG
    
    pl " Now checkout the file, with lock:"
    co -l $FILE
    
    pl " Current files after  checkout:"
    ls -lgG
    
    pl " Modify and checkin the file, effectively keeping the lock:"
    sed -i -e '/two/d' -e '$a\
    four' $FILE
    head $FILE
    ci -l $FILE <<<' Second edition.'
    
    pl " Current files after  modification and checkin:"
    ls -lgG
    
    pl " Display the modified file:"
    head $FILE
    
    pl " List the log and details of hi.txt:"
    rlog hi.txt
    
    exit 0
    producing:
    Code:
    % ./s1
    
    Environment: LC_ALL = C, LANG = C
    (Versions displayed with local utility "version")
    OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
    Distribution        : Debian GNU/Linux 5.0.8 (lenny) 
    bash GNU bash 3.2.39
    sed GNU sed version 4.1.5
    ci RCS version 5.7
    co RCS version 5.7
    
    -----
     Current files before operations:
    total 8
    -rw-r--r-- 1  269 May 25 08:42 readme.txt
    -rwxr--r-- 1 1114 May 25 09:39 s1
    
    -----
     Data file hi.txt:
    one
    two
    three
    
    -----
     Current files before checkin:
    total 12
    -rw-r--r-- 1   14 May 25 09:46 hi.txt
    -rw-r--r-- 1  269 May 25 08:42 readme.txt
    -rwxr--r-- 1 1114 May 25 09:39 s1
    
    -----
     Checking in file hi.txt (simulated comment supply):
    hi.txt,v  <--  hi.txt
    initial revision: 1.1
    done
    
    -----
     Current files after  checkin:
    total 12
    -r--r--r-- 1  210 May 25 09:46 hi.txt,v
    -rw-r--r-- 1  269 May 25 08:42 readme.txt
    -rwxr--r-- 1 1114 May 25 09:39 s1
    
    -----
     Now checkout the file, with lock:
    hi.txt,v  -->  hi.txt
    revision 1.1 (locked)
    done
    
    -----
     Current files after  checkout:
    total 16
    -rw-r--r-- 1   14 May 25 09:46 hi.txt
    -r--r--r-- 1  223 May 25 09:46 hi.txt,v
    -rw-r--r-- 1  269 May 25 08:42 readme.txt
    -rwxr--r-- 1 1114 May 25 09:39 s1
    
    -----
     Modify and checkin the file, effectively keeping the lock:
    one
    three
    four
    hi.txt,v  <--  hi.txt
    new revision: 1.2; previous revision: 1.1
    done
    
    -----
     Current files after  modification and checkin:
    total 16
    -rw-r--r-- 1   15 May 25 09:46 hi.txt
    -r--r--r-- 1  354 May 25 09:46 hi.txt,v
    -rw-r--r-- 1  269 May 25 08:42 readme.txt
    -rwxr--r-- 1 1114 May 25 09:39 s1
    
    -----
     Display the modified file:
    one
    three
    four
    
    -----
     List the log and details of hi.txt:
    
    RCS file: hi.txt,v
    Working file: hi.txt
    head: 1.2
    branch:
    locks: strict
    	drl: 1.2
    access list:
    symbolic names:
    keyword substitution: kv
    total revisions: 2;	selected revisions: 2
    description:
     First version.
    ----------------------------
    revision 1.2	locked by: drl;
    date: 2012/05/25 14:46:51;  author: drl;  state: Exp;  lines: +1 -1
     Second edition.
    ----------------------------
    revision 1.1
    date: 2012/05/25 14:46:51;  author: drl;  state: Exp;
    Initial revision
    =============================================================================
    Comments:

    1) You should be able to copy and paste this script into a file on your GNU/Linux system,

    2) You didn't mention your platform, so I cannot advise you on how to install the rcs package if it is not already installed,

    3) Your system will not be able to produce all of the environment or versions because that is a utility local to our organization.

    See man pages for details.

    Best wishes ... cheers, drl

    ( Edit 1: correct minor spelling error )
    Last edited by drl; 05-26-2012 at 09:57 AM.
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  9. #9
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    185
    is this a text file? how often is the file updated? do you update it or is it updated automatically? Do you want back-ups of the old file? It could be a very simple script.

  10. #10
    Just Joined!
    Join Date
    Aug 2011
    Posts
    10
    Quote Originally Posted by mactruck View Post
    is this a text file?
    its a puppy linux save file. I believe it's binary ext3, with a lot of white space.
    puppylinux.org/wikka/SaveFile

    how often is the file updated?
    manually, not scheduled. Could be 3 in a day, then a month before the next one.

    Do you want back-ups of the old file?
    i dont understand the question.

    i'm now looking at these methods, which seem simpler than the suggestion above:
    the 'diff' command and then you use the 'patch' command.... rdiff-backup would also work to keep one current copy of the puppy save file, and "binary diffs" that would allow recovery of a previous save file
    murga-linux.com/puppy/viewtopic.php?p=629862#629862

    If you have an alternative, would love to hear it.

    thanks

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •