RSYNC - manual backup

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Post Reply
User avatar
BiB
Level 2
Level 2
Posts: 69
Joined: Wed Jul 15, 2020 5:26 pm
Location: central EUROPE

RSYNC - manual backup

Post by BiB »

Hi everybody,

I still kinda use the rsync command to backup my OS and my Office files. I don't work in IT, just use linux, if you have a different suggestion for me how to "back up", tell me plz ;-)
I wrote a shell with around 10 commands in it - they all do the rsync and work fine. Just these 2 lines and the bottom seem not to work.
Does anyone see why?

So here is the shell:

Code: Select all

rsync -ahv --delete --exclude-from=exclude.WIN.txt /mnt/win/ /mnt/hdd/rsync_WIN_powerhost_AKTUELL.uefi &&
rsync -ahv --delete /boot/efi /mnt/hdd/rsync_efi_powerhost_AKTUELL.uefi/ &&
rsync -ahv --delete /opt/* /mnt/main/rsync_NOMEDIA/opt/ &&

rsync -ahv --delete /mnt/share/MOZILLA* /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/share/Brave* /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/share/chromium* /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/lbry/secret_data /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/hdd/*.sh /mnt/lbry/pukkab/MAIN &&
rsync -ahv --delete /mnt/hdd/exclude* /mnt/lbry/pukkab/MAIN && date && df -h
looking closer:

Code: Select all

rsync -ahv --delete --exclude-from=exclude.WIN.txt /mnt/win/ /mnt/hdd/rsync_WIN_powerhost_AKTUELL.uefi &&
rsync -ahv --delete /boot/efi /mnt/hdd/rsync_efi_powerhost_AKTUELL.uefi/ &&
rsync -ahv --delete /opt/* /mnt/main/rsync_NOMEDIA/opt/ &&
So this saves my windows 10 partition and some /opt. I don't know what microsoft suggests doin, but I do it like this. works so far.

Code: Select all

rsync -ahv --delete /mnt/xxx/MOZILLA* /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/xxx/Brave* /mnt/hdd/rsync_NOMEDIA/ &&
rsync -ahv --delete /mnt/xxx/chromium* /mnt/hdd/rsync_NOMEDIA/ &&
These are my manually exported bookmarks. No matter the file ending (dates usually), I just noticed they are not backed up.

Code: Select all

rsync -ahv --delete /mnt/lbry/secret_data /mnt/hdd/rsync_NOMEDIA/ &&
Also this works. as you may have noticed my destination is an external hdd on which I got the backup.

Code: Select all

rsync -ahv --delete /mnt/hdd/*.sh /mnt/lbry/pukkab/MAIN &&
rsync -ahv --delete /mnt/hdd/exclude* /mnt/lbry/pukkab/MAIN && date && df -h
and this is the last command, where I backup the actual script I am using and the exclude file. However this does not work. The destination "lbry" is a btrfs partition, but this shouldn't be an issue, should it?
Why does it not work? Does rsync not understand the * ? Please..
Love Linux OS
OS: Win10 custom & Feren OS & Linux Mint & Alpine
CPU: Intel Xeon E5-1650 v3 (12) @ 3.800GHz
Still kind of a newbie sometimes - so thanks for the help!
User avatar
BiB
Level 2
Level 2
Posts: 69
Joined: Wed Jul 15, 2020 5:26 pm
Location: central EUROPE

Re: RSYNC - manual backup

Post by BiB »

Code: Select all

#!/bin/sh

## Operating Systems
rsync -ahv --delete --exclude-from=exclude.WINGAMES.txt /mnt/win/ /mnt/main/rsync_WIN_powerhost_GAMES.uefi &&
rsync -ahv --delete --exclude-from=/mnt/main/exclude.nomedia.txt /home/ /mnt/main/rsync_HOME.uefi &&
rsync -ahv --delete /boot/efi /mnt/main/rsync_efi_powerhost_AKTUELL.uefi/ &&
Hey, sorry guys, I put up the original beginning of my XXX.sh File which I run by

Code: Select all

bash XXX.sh
Maybe the file is not written correct or chaining the commands with && is the problem?

Thanks if anyone could help.

B
Love Linux OS
OS: Win10 custom & Feren OS & Linux Mint & Alpine
CPU: Intel Xeon E5-1650 v3 (12) @ 3.800GHz
Still kind of a newbie sometimes - so thanks for the help!
User avatar
Lady Fitzgerald
Level 15
Level 15
Posts: 5821
Joined: Tue Jan 07, 2020 3:12 pm
Location: AZ, SSA (Squabbling States of America)

Re: RSYNC - manual backup

Post by Lady Fitzgerald »

I'm lazy. I use FreeFileSync (FFS). After the initial setup of configurations, I just connect my backup drives, click on the configurations that correspond to the backup drives, then start the process and let FFS do all the work. It even verifies each file copy and send files deleted from the backup drive to a Versioning folder so I can make sure I want those files deleted before actually deleting them (prevents data loss due to previous accidental deletions or file corruption).
Jeannie

To ensure the safety of your data, you have to be proactive, not reactive, so, back it up!
1000
Level 6
Level 6
Posts: 1040
Joined: Wed Jul 29, 2020 2:14 am

Re: RSYNC - manual backup

Post by 1000 »

- The script or command should return an error if something doesn't work.

- I don't know what purpose you used " && " for.
I hope you know how it works.
allows the second command to run only if the first command is successful
- You can expand the script with additional messages or create with script rsync.log file.
For example
_ * when one job copying is finished successfully
_ * when a file or folder is larger than the amount of free space in the destination.

- Check if files or folders exist to be copied.

- Check if there is enough space, where you want copy

You can do it?

Edited

- And check if you can copy the files, even manually if you can.
_ * If you can't, you may not have permissions.
_ * If you can, but the copying is interrupted, maybe you see an error?
Post Reply

Return to “Scripts & Bash”