LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   could someone "please" check 2 rsync commands I'm not sure the structure is right. (https://www.linuxquestions.org/questions/ubuntu-63/could-someone-please-check-2-rsync-commands-im-not-sure-the-structure-is-right-4175671736/)

bsurfin 03-21-2020 12:15 AM

could someone "please" check 2 rsync commands I'm not sure the structure is right.
 
I've been working on this for 2 weeks, I'd like someone that knows what they are doing with rsync to tell me if this should work on my Ubuntu 18.04 machines.

This works great, for making a backup and keeping it in sync exactly as it is on the server, same permissions and everything, I figured this out a couple years ago, it has worked perfect.
sudo rsync -r -t -p -o -g -v --progress --delete -l -H -D -s /mnt /media/jason/USB Backup/Backup
I noticed the format is sudo rsync options /source /target


I Modified the rsync commands I found on the internet below, I noticed that these have the / as the source directory in the middle of the options, or do I need to move that towards the end right before the destination directory ? this is why rsync is confusing so far, everyone seems to do it a little different, should these work ?

this one to backup my laptop:
sudo rsync -aAXv / --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found",”swapfile”,”.encryptfs”} /target


This one to help me turn my server into a virtual server, by copying the following to the guest HDD with a fresh ubuntu 18.04 install on my kvm server:
sudo rsync -auHxv / --exclude={"/etc/fstab*","/etc/network/*","/proc/*","/tmp/*","/sys/*","/dev/*","/mnt/*","/boot/*","/root/*",”swapfile”,"/lost+found"} /target

The people putting these on the internet seemed confident, but I'm not sure the structure is right since the --exclude is after the / source directory.

Turbocapitalist 03-21-2020 12:28 AM

You can try the --dry-run option first to make sure it is ok. For exclusion, I prefer to use --filter instead of --exclude.

fatmac 03-21-2020 05:54 AM

Normally all options come after the command & before the directories to be worked on in Linux, so try that if the above doesn't solve it for you.

bsurfin 03-21-2020 08:46 PM

The source does go right before the destination in my case, I believe the directions I got above was for using the command for backing up through ssh, which apparently you can enter the source in earlier in the command, then the ssh:/* goes right before the destination if I understand what I found out today correctly.

Turbocapitalist 03-21-2020 11:57 PM

The rsync utility uses SSH for transfer by default since version 2.6, and that was released back in 2004. So even if you are on CentOS, you don't have to add anything to use basic SSH.

However, if you'd like to pass options to the SSH client then you would still need to have the -e option for rsync. That would come in handy if you have a different account name on the remote computer or will use a key to connect:

Code:

sudo rsync -aAXv \
        --dry-run \
        --delete \
        -e 'ssh -l nifrusb -i /home/bsurfin/.ssh/some_key_rsa' \
        --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*",\
            "/run/*","/mnt/*","/media/*","/lost+found",”swapfile”,”.encryptfs”} \
        / /target


bsurfin 03-24-2020 05:56 PM

Thanks for the code, as it was the next script I needed to figure out. Once I get everything transferred over, Since my 4TB backup USB is running out of space. I planned on using my old server for a backup server and would then need to transfer ( 8TB LVM to 8TB LVM "For Now") with rsync and ssh, rsync is the fastest way of backing up that I've come across.


All times are GMT -5. The time now is 02:08 AM.