Results 1 to 5 of 5

Thread: How to setup my rsync in a script

  1. #1
    Join Date
    Aug 2009
    Beans
    13

    How to setup my rsync in a script

    Hi all

    I do use rsync on the commandline at the moment. But I would like to execute all my 5 rsync's with one click, and then possibly automatically shutdown the computer. How can I do this?


    my commands are doing the following (the last two go to a nfs-share on a NAS)

    rsync -r -t -p -o -g -v --progress --delete --exclude=.* --log-file=/home/roberto/i3vmssd.txt --log-file-format= -l -H -s /media/i3vmssd/i3vmmint /media/vmandimages/vmandimages/vm

    rsync -r -t -p -o -g -v --progress --delete --exclude=.* --log-file=/home/roberto/homei3host.txt --log-file-format= -l -H -s /media/homei3host/roberto /media/homei3hostbk

    sudo rsync -r -t -p -o -g -v --progress --delete --exclude=.* --log-file=/home/roberto/vmandimages.txt --log-file-format= -l -H -s /media/vmandimages/vmandimages /media/vmandimagesbk

    rsync -r -t -p -o -g -v --progress --delete --exclude=.* --log-file=/home/roberto/homei3hostdatanas.txt --log-file-format= -l -H -s -b --backup-dir=`date +%Y-%m-%d` /media/homei3host/roberto /media/datanas

    rsync -r -t -p -o -g -v --progress --delete --exclude=.* --log-file=/home/roberto/vmandimagesdatanas.txt --log-sudo file-format= -l -H -s -b --backup-dir=`date +%Y-%m-%d` /media/vmandimages/vmandimages /media/datanas

    so can I just put all in a file starting "#!/bin/bash" and just ending with the last command?

    thanks
    Roberto

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: How to setup my rsync in a script

    That would be a reasonable starting point for a script.

    If you want to shut down at the end, something like:

    Code:
    sudo poweroff
    You might also want to define some variables to refer to the directories and common options so that it's easier to maintain, for example:

    Code:
    RSYNC_OPTIONS="-r -t -p -o -g -v --progress --delete"
    VM_IMAGES="/media/i3vmssd/i3vmmint /media/vmandimages/vmandimages/vm"
    
    rsync $RSYNC_OPTIONS --exclude=.* --log-file=/home/roberto/i3vmssd.txt --log-file-format= -l -H -s "$VM_IMAGES"
    ...
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

  3. #3
    Join Date
    Feb 2009
    Beans
    23

    Re: How to setup my rsync in a script

    To make the script executable you may also want to do chmod +x <script_name>

  4. #4
    Join Date
    Jun 2009
    Location
    Chicago Suburbs
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to setup my rsync in a script

    You will not need nor should have sudo in the file.

    A simple example.
    Originally Posted by MountainX View Post #20 also other backup apps
    http://ubuntuforums.org/showthread.p...ghlight=backup
    Sample rsync file, use a text editor and paste into a file & name it mybackup.sh


    Some folders to exclude from /home:
    http://ubuntuforums.org/showthread.php?t=1883834


    Some more examples:
    http://rsync.samba.org/examples.html

    Backup to external with check of mounted & email
    http://ubuntuforums.org/showthread.php?t=1701292

    rsync confirmation list:
    http://ubuntuforums.org/showthread.php?t=1692800
    Check for mount of backup partition
    http://ubuntuforums.org/showthread.php?t=1701292
    http://ubuntuforums.org/showthread.php?t=1555647&page=4
    more scripts:
    http://ubuntuforums.org/showthread.php?t=1319155
    Oldfred on vacation. Back Sept 9. Will not have much if any Internet access.
    For info on UEFI boot install & repair:
    http://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to close thread when/if answered completely.







  5. #5
    Join Date
    Aug 2009
    Beans
    13

    Re: How to setup my rsync in a script

    thanks for all the information!

    cheers
    Roberto

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
  •