backup.rkt
#lang racket/base

(require (only-in "pipe-between.rkt" pipe-between)
          (only-in "gui-system.ss" copy-file)
          (prefix-in temp: (planet synx/util:2/temp)))

(define (incremental dump base name)
   (define base-file (build-path base name))
   (if (not (file-exists? base-file))
     (begin (dump base-file) (copy-file base-file name))
     (temp:with-file
      (λ (holder)
        (define delta (string-append name ".xdelta"))
        (dump holder)
        (pipe-between
         ("xdelta"
          "delta"
          (path->string base-file)
          (path->string holder)
          delta))
        (when (> (file-size delta) (file-size base-file))
          (delete-file delta)
          (dump base-file)
          (copy-file base-file name))))))

(provide incremental)