Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Can someone help me with my backup script?

  1. #11
    Join Date
    Oct 2009
    Beans
    79
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can someone help me with my backup script?

    Viva la Google! I've found the answer! I'm surprised I missed this in the man pages

    Code:
    Sudo chown -R dillan /home/dillan/bak
    All I needed was the -R to include the contents of the directory.

    So I just tested it, and everything worked! Success after debugging for a while is so nice isn't it? Thank you everyone for your assistance, you all rock. I don't know where I'd be without ubuntuforums!

    EDIT: Here's the completed script, just for reference:

    Code:
    #!/bin/bash
    
    # Backs up files, cleans out the junk, then turns off the computer
    
    ##### Backup #####
    rsync -ruv --delete /media/files /home/dillan/bak
    chown -R dillan /home/dillan/bak/
    
    ##### Clean #####
    apt-get autoclean && apt-get clean
    
    ##### Shutdown #####
    shutdown -h now
    Last edited by dillandriskell; December 27th, 2009 at 08:27 AM.

  2. #12
    Join Date
    Oct 2009
    Beans
    79
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can someone help me with my backup script?

    Ohh! One more thing I forgot. I would also need to "safely remove" my external drive and wait for it to finish before shutting down my computer. Is "Safely remove hardware" the same as "unmount"? I remember I used unmount in 9.04 without consequence.

    If that's the case then I just need to add umount <name of drive> to the script right? Or is there another BASH command for safely removing hardware? And how would I go about finding the name of the drive? I think I need to use something other than the name I gave it (files) and I think I can access it with some command like "ffdisk -l" or something like that. Does anybody know what I'm talking about?

  3. #13
    Join Date
    Oct 2009
    Beans
    79
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can someone help me with my backup script?

    Bump.

    I found out that the proper term I was thinking of was fdisk -l, and the drive's name was /dev/sdb1. Though I'm still not sure if I should be using /dev/sdb1 or just files.

  4. #14
    Join Date
    Dec 2006
    Beans
    258

    Re: Can someone help me with my backup script?

    I think you should be able to get rsync to preserve your user and group information. Try

    Code:
    rsync --recursive --update --verbose --delete --perms --owner --group /media/files /home/dillan/bak
    Just a note on the way I do it, I find in scripts it is easier to see what you did using the long options. 2 months from now, when you want to change something, the above options are a lot easier to read than rsync -ruvpog --delete

  5. #15
    Join Date
    Oct 2009
    Beans
    79
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can someone help me with my backup script?

    Quote Originally Posted by Mister.Vash View Post
    I think you should be able to get rsync to preserve your user and group information. Try

    Code:
    rsync --recursive --update --verbose --delete --perms --owner --group /media/files /home/dillan/bak
    Just a note on the way I do it, I find in scripts it is easier to see what you did using the long options. 2 months from now, when you want to change something, the above options are a lot easier to read than rsync -ruvpog --delete
    I tried that and success! So thank you for that, I think I prefer just doing it that way as oppose to changing all the permissions then changing them back lol. And I added the long options, as your logic behind that is right. I've done that soo many times, I've got to get in the habit.

    As far as safely removing it goes, I figured out it was in fact the same thing as unmount. I also found out how to do it. Which all it was is;

    Code:
    sudo umount <name of drive>
    And you use the name shown right on the desktop when you plug it in (for me it was "files"). But here's the worst bit, after an hour of research I finally figured out that the computer unmounts it for me upon shutdown automatically, so it was completely unnecessary to explicitly tell it to do so. /facepalm

    I'm pretty sure I've got this figured out now, so thanks again everyone for your help and putting up with me doing wayy more than I needed to lol.

Page 2 of 2 FirstFirst 12

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
  •