Announcement

Collapse
No announcement yet.

Don't have regrets - have backups - using rdiff-backup

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Don't have regrets - have backups - using rdiff-backup

    Here is my method for maintaining a simple backup of my Kubuntu /home and /etc folders. It is one way to be able to recover when things have gone badly wrong.
    This method does not back up files from other operating systems.
    Need to recover a deleted file? Lost your operating system and need to re-install from scratch? This method is your friend.
    I am not a computer expert, so although this method does work - there might very well be better ways to achieve the same goal.
    Any comments, suggestions, corrections, are very welcome.

    This is a medium level set of instructions, it assumes that you have a separate hard drive, that it has a partition table and space for a backup partition.
    It also assumes your familiarity with use of the terminal and your ability to edit system files like /etc/fstab and /etc/crontab

    Warning: make mistakes in some of these operations and your computer could stop functioning correctly


    1. set up and format a partition, on a separate drive, about double the volume of the files you will back up

    2. create a folder /mnt/backup:
    Code:
    sudo mkdir /mnt/backup
    make yourself owner of the file (substitute your user name for 'username') :
    Code:
    sudo chown -R username:username /mnt/backup

    3. create an entry for /mnt/backup in /etc/fstab so that the partition will be mounted:

    find the UUID of your backup partition using:
    Code:
    sudo blkid
    then:
    Code:
    kdesudo kate /etc/fstab
    first save fstab as /etc/fstab.bkup

    then add this line to your fstab:
    Code:
    UUID=(uuid of your backup partition)	/mnt/backup (format type here) defaults 0 2
    in format type put the formatting for your partition, ext3,ext4,btrfs etc
    save your fstab as /etc/fstab, making sure there is a blank empty line at the end of the fstab text and close


    4. put a sub-folder in /mnt/backup - call it /mnt/backup/info

    Code:
    mkdir /mnt/backup/info

    5. write some scripts and save them into the /mnt/backup/info folder
    (edit the include and exclude folders according to your needs)

    Code:
    /home/
    /etc/
    (save the above as /mnt/backup/info/backup.include)

    Code:
    /home/bob/.adobe/
    /home/bob/.dbus/
    /home/bob/.macromedia/
    /home/bob/.thumbnails/
    **.iso
    (save the above as /mnt/backup/info/backup.exclude)

    Code:
    #!/bin/bash
    #
    # local-backup v1.0
    # script by bob 
    # published on kubuntu forums 
    # purpose - to make simple (hourly) backups to a dedicated partition
    # 
    # backup partition is /mnt/backup/
    # data files are in /mnt/backup/info
    # backups will appear in /mnt/backup/store
    #
    # This method is offered in the hope that it may be useful
    # No liability is accepted for any consequences arising from its use 
    #
    
    /usr/bin/rdiff-backup --exclude-globbing-filelist /mnt/backup/info/backup.exclude \
        --include-globbing-filelist /mnt/backup/info/backup.include \
        --exclude / / /mnt/backup/store/ 
    
    # The following line removes restores which have been current for over [2] days
    
    /usr/bin/rdiff-backup --remove-older-than 2D --force /mnt/backup/store/
    (save the above as /mnt/backup/info/local-backup)


    6. make local-backup executable
    Code:
    chmod +x /mnt/backup/info/local-backup
    (do not put any kind of file extension on 'local-backup' - that would prevent it from working)


    7. download and install the backup program, rdiff-backup
    Code:
    sudo apt-get install rdiff-backup

    8. place a copy of local-backup in /etc/cron.hourly to get hourly backups
    Code:
    sudo cp /mnt/backup/info/local-backup /etc/cron.hourly

    9. edit /etc/crontab so that backups are on the hour
    as always backup up your crontab - save as /etc/crontab.backup
    Code:
    kdesudo kate /etc/crontab
    then edit the hourly line to read:
    Code:
    0  *	* * *	root    cd / && run-parts --report /etc/cron.hourly
    save as /etc/crontab


    10. wait until the hour has past and check that everything is running smoothly by running this code:
    Code:
    sudo rdiff-backup -l /mnt/backup/store
    which will will report on backups made


    11. use the following code to activate backup at shut-down & reboot (this WILL cause a slow-up at shut-down while files are saved)
    Code:
    sudo cp /mnt/backup/info/local-backup /etc/init.d
    sudo ln -s /etc/init.d/local-backup /etc/rc0.d/K10local-backup
    sudo ln -s /etc/init.d/local-backup /etc/rc6.d/K10local-backup

    12. NEVER manually edit the files in /mnt/backup/store it will cause a system malfunction

    Enjoy a more secure system and check out rdiff-backup on the net to discover how to recover files
    If you have suggestions for improvements then please comment here. How was it for you? Feedback is always welcome.
    The scripts can be edited to personalize inclusions and exclusions, backups can be retained for a longer or shorter period to suite the user.
    Last edited by bobbicat; Jul 03, 2014, 10:49 PM.

    #2
    A worthy post!

    Don't be a stranger around here! lol

    woodsmoke

    Comment


      #3
      Nice instruction set, bobbiecat.

      When I installed Kubuntu 14.04 I decided to give btrfs a try, instead of ext4. Glad I did. Awesome fs. It has amazing and easy ways to create backups, either full or incremental If one is going to use a second HD then syncing a full backup might be the best route. Here are instructions on incremental backups on a btrfs system:
      https://btrfs.wiki.kernel.org/index....emental_Backup
      http://arstechnica.com/information-t...filesystems/3/

      There are some threads on this forum about btrfs:
      https://www.kubuntuforums.net/showth...btrfs+greygeek
      https://www.kubuntuforums.net/showth...btrfs+greygeek
      https://www.kubuntuforums.net/showth...btrfs+greygeek
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Thanks for the input. There is no doubt, I WILL be back woodsmoke
        You are too kind, gentlemen - though I do detect pressure to dip a toe in the waters of BTRFS
        It is on my mind to make a second install of Kubuntu, a test bed for that file system
        I will study the links you have provided, GreyGeek and see where they take me
        ...probably right back here to these Forums, where I will no doubt have questions and comments to make

        Comment


          #5

          woodlookingforwardtoyourinputsmoke

          Comment


            #6
            Who, us? Putting (btrfs) pressure on you (btrfs) to try a certain files (btrfs) system? Nah.....
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment

            Working...
            X