Search code examples
backuprsyncrdiff-backup

rdiff-backup: Backup whole folder instead of his contents


I have a issue about a backup procedure with rdiff-backup. Let's say that i want to make a backup in the following way:

rdiff-backup foo /media/bar

When I do that, all the contents of "foo" are stored in "/media/bar/", but not "foo" itself. This is a problem to me because I want to backup multiple directories with the --include-globbing-filelist include-list option, if I do this, all the contents of the folders listed in include-list will be messy in the destination folder.

With rsync, if I do:

rsync -a foo /media/bar

"foo" and all of his contents will be transferred to "/media/bar" instead of his contents only.

So, is there any way to backup "foo" instead of only his contents?


Solution

  • Method 1

    rdiff-backup foo /media/bar/foo
    

    ... just saying. ;-)

    Method 2

    Create an include list like this:

    /home/me/foo
    /home/me/other-foo
    - /**
    

    Then backup like this:

    rdiff-backup --include-globbing-filelist include-list / /media/bar
    

    In other words, tell rdiff-backup to backup everything, but then exclude everything you don't explicitly mention with the catch-all - /** rule at the foot of the include file.

    My example starts at the root directory, but you could start at any level you like:

    /foo
    /other-foo
    - /**
    

    and

    rdiff-backup --include-globbing-filelist include-list /home/me /media/bar
    

    I like to start at root because a) it gives me maximum freedom to include and exclude stuff later, and b) I'm backing up some files from /etc anyway.