Results 1 to 10 of 11

Thread: Need to Make Backup Script for Multiple Directories

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Beans
    5

    Need to Make Backup Script for Multiple Directories

    Hello,

    I am very new at all this server stuff. I am needing to make a backup script to backup individual users home directories to a backup server on the same LAN. I need to keep a minimum of 8 backups, and backups need to happen at one hour intervals. I also need a way to restore any files the users may accidentally delete back to their home directory. I am using Ubuntu 12.04.1. Any help I could get would be greatly appreciated, I have had almost no scripting experience at all, so any pointers you could give would be great

    Thanks!!

  2. #2
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Need to Make Backup Script for Multiple Directories

    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  3. #3
    Join Date
    Nov 2012
    Beans
    5

    Re: Need to Make Backup Script for Multiple Directories

    This is what i tried for a test backup. You will probably laugh when you read it, but I'm VERY new at this. Could someone take a look and tell me why I'm getting the errors i'm getting please?

    Code:
    #!/bin/bash
    
    FILE="testbackup`date +%Y.%m.%d.%H.%M`.tgz"
    FOLDER="/home/justin/"
    
    tar czf $FOLDER > $FILE
    scp $FILE jvore@10.17.4.235:/home/jvore/backups
    Returns

    Code:
    tar: Cowardly refusing to create an empty archive
    Try `tar --help' or `tar --usage' for more information.
    testbackup2012.11.28.15.57.tg 100%    0     0.0KB/s   00:00
    Any help would be appreciated!
    Last edited by Voreskin; November 29th, 2012 at 01:01 AM.

  4. #4
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Need to Make Backup Script for Multiple Directories

    Quote Originally Posted by Voreskin View Post
    This is what i tried for a test backup. You will probably laugh when you read it, but I'm VERY new at this. Could someone take a look and tell me why I'm getting the errors i'm getting please?

    Code:
    #!/bin/bash
    
    FILE="testbackup`date +%Y.%m.%d.%H.%M`.tgz"
    FOLDER="/home/justin/test/"
    
    tar czf $FOLDER > $FILE
    scp $FILE jvore@10.17.4.235:home/jvore/backups
    Returns

    Code:
    ./backup.sh: line 6: gt: command not found
    tar: ./backup.sh: line 6: testbackup2012.11.28.15.47.tgz: command not found
    Cowardly refusing to create an empty archive
    Try `tar --help' or `tar --usage' for more information.
    testbackup2012.11.28.15.47.tgz: No such file or directory
    Any help would be appreciated!
    Why beat yourself up? The scripts are already written for rsync. The app/scripts is called rsnapshot. See here for information.

    Just configure it and it will do exactly what you want.
    -BAB1

  5. #5
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Need to Make Backup Script for Multiple Directories

    Just so you'll know why the tar command did not work, if you use the "f" parameter it expects the name of the tar file to follow immediately thereafter like this

    Code:
    tar czpf $FILE $FOLDER
    You definitely need to include the "p" option to preserve the ownerships, permissions, and datestamps on the files. If you replace "z" with "j" it uses the slower to create, but more compressed bzip2 format. If you add "v", you'll get a list of the files being stored.

    If you want to see an example where multiple backups are rotated, see this posting.
    Last edited by SeijiSensei; November 29th, 2012 at 02:15 AM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  6. #6
    Join Date
    Nov 2012
    Beans
    5

    Re: Need to Make Backup Script for Multiple Directories

    Thank you all! It's so nice to have a place where noobs like me can go to get some professional help! It's people like you that make Linux fun!

    I will start off with the rsnapshot, and see where that gets me!

Tags for this Thread

Bookmarks

Posting Permissions

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