0

I would like to generate diffs for the sake of doing incremental backups of an sql database.

Using the standard unix 'diff' tool generates unnecessarily large files, since they include the full text of deleted lines. I only need support to be able to patch in one direction (to generate the current db dump from the full dump and an incremental patch).

How would I go about doing this? I have tried so far using diff -e and patch -e, but it doesn't seem to be working correctly, as the resulting file is corrupt (possibly an issue with the 'ed' tool used in cygwin)

idle
  • 1,117
  • 9
  • 17
  • 1
    I don't get why you don't need the deleted lines to recreate the full dump. If rows disappear, don't you need to delete them? – drysdam Oct 06 '11 at 01:18
  • I need the information that the lines were deleted, but not the actual content of those lines. For example 1.txt: 1\n 2\n 3\n 4 2.txt: 1\n 3\n 4\n 5 Give the diff 2d1 < 2 4a4 > 5 Storing that the text "2" was removed is wasteful, since I only need the fact that line number 2 (whatever it contained) was deleted. Keeping it is necessary if I need to go both directions (ie apply the diff to 2.txt to end up with 1.txt), but not if I only need one direction – idle Oct 06 '11 at 05:53

1 Answers1

1

back in the old days, before Vim, there used to be a line-oriented UNIX editor called 'ed' ..

diff has an option built in ( -e option ) , with which you can create an edit script from the diff.

Check here: and look for the section "Edit Script"

http://en.wikipedia.org/wiki/Diff

http://docs.freebsd.org/info/diff/diff.info.ed_Scripts.html

here's an example:

http://www.araxis.com/merge/topic_diff_report_editscript.html


another way to do this is to create a patch file (see 'man patch')

Tilo
  • 33,354
  • 5
  • 79
  • 106
  • I think this is the best option. It seems that the cygwin version of ed might have some issues that are the only reason it hasn't been working correctly for me. – idle Oct 06 '11 at 05:57