Results 1 to 7 of 7

Thread: rsync doubt

  1. #1
    Join Date
    Mar 2013
    Beans
    91

    rsync doubt

    Hello all

    I need an additional clarification about the use of rsync. Normaly i use to backup Home Folder from an old Linux Workstation to an new one, and i use this command:

    rsync -avz /home/username/ username@hostname:/home/username --exclude=".*"

    • if i need to exclude all the hidden files/folders is correct the option --exclude=".*"
    • Sometimes it happened like today, that the new workstation is never used(for weeks or months) and we would need to re-run an rsync to update the "backup" running again:


    rsync -avz /home/username/ username@hostname:/home/username --exclude=".*"
    I thought it was going to copy only the difference, basically all the modified files in the source(the new workstation was never touched) but i have the suspect that it copying again all the file, because the Rsync it has been running for 15 hours.

    Where am I doing wrong?

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    18,830
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: rsync doubt

    --dry-run is very helpful.

    I would start by testing something like this if not getting dotfiles is desired.
    Code:
    rsync -avz  --dry-run --exclude="/home/*/.*"      /home/username/     username@hostname:/home/username/
    Note the order and trailing slash on the target. In theory, the trailing slash on the target shouldn't matter, but ...

    .* alone matches much more than just config files.

    If you need more exact control, using the --exclude-from=list-o-exclude-files.txt is handy.

    For the target to be just like the source, might need to add --delete to the options. rsync is additive unless explicitly told to delete any files in the target that do not exist in the source. There are a few different --delete-.... options, depending on how much excess storage the target directory has and whether deleting after, before or during is needed.

  3. #3
    Join Date
    Mar 2013
    Beans
    91

    Re: rsync doubt

    Wth the --exclude option sometimes we want to exclude configuration files because it can happend to pass from an ubuntu 14.04 to an 18.04 and also from Fedora to ubuntu 18.04 and we don't want overwrite configuration files over the new Workstation with the new software installed.

    we have also a scenario where a user has two old workstation and we need to rsync two home over the new workstation and normally we back the younger with the command i mentioned before:


    1. rsync -avz /home/username/ username@hostname:/home/username --exclude=".*"


    Then we create an additional folder on the new workstation where to copy the home folder of the older computer:


    1. rsync -avz /home/username/ username@hostname:/home/username/Older_Workstation --exclude=".*"



    To use the --delete option is dangerous unfortunately i have to run the 1st command again it will delete the Older_Worlstation folder, right?

    but apart the --exclude option what i really feel is that the rsync is copying everything again......maybe it could be the missing / on the destination......i don't know....

    Last edited by giobaxx; 4 Weeks Ago at 10:31 PM.

  4. #4
    Join Date
    Aug 2005
    Location
    Northern Michigan USA
    Beans
    2,196
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: rsync doubt

    I do an grsync every week. One with /home and one with / but here are the excludes I put in
    Code:
    --exclude '/cdrom'
    --exclude '/dev'
    --exclude '/home'
    --exclude '/lost+found'
    --exclude '/media'
    --exclude '/mnt'
    --exclude '/proc'
    --exclude '/run'
    --exclude '/sys'
    --exclude '/tmp'
    --exclude '/.cache'
    --exclude '/.Trash-0'
    I am also posting 4 pics of the options I put which seem to work real well and the excludes setup
    Attached Images Attached Images
    • File Type: png 1.png (47.8 KB, 4 views)
    • File Type: png 2.png (63.9 KB, 3 views)
    • File Type: png 3.png (50.4 KB, 2 views)
    • File Type: jpg 4.jpg (32.8 KB, 2 views)
    • File Type: png 3.png (87.7 KB, 3 views)
    Last edited by cmcanulty; 4 Weeks Ago at 11:52 PM.

  5. #5
    Join Date
    Oct 2005
    Location
    Al Ain
    Beans
    9,767

    Re: rsync doubt

    Hmm, I'm not sure about that '.*'

    In Bash, '*' includes a '.', therefore '.*' will expand to '..', which may indicate the previous directory and not do what you want.

  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    18,830
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: rsync doubt

    Exactly Herman. That's why I used the path with multple wildcards.

    Never underestimate the utility of --dry-run either.

  7. #7
    Join Date
    Mar 2013
    Beans
    91

    Re: rsync doubt

    Hello Guys just some update

    I've made some test with two very simple virtual Machine and the exclude =".*" seems to work but to be sure i want to try to run the rsync with the --dry-run as advised by @TheFu to try to understand the behavior of the Rsync with the option exclude =".* about the problem mentioned by HermanAB.

    About the problem to run a second or a third rsync to update modified files/folders on the source i asked to a collegue that is an advanced linux user and he told me to use the following option rsync -auvz sources destination, even if i tried to run rsync in the two simple VM created by me and the rsync -avz sources destination work perfectly.

    I have added a file in the sources VM and Running a second rsync only that file was copied from the source to the destination...i will try again this week...

    HermanAB
    Last edited by giobaxx; 3 Weeks Ago at 01:33 PM.

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
  •