Rsync restoring a compressed version

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
szymon1051
Level 2
Level 2
Posts: 94
Joined: Sun Apr 23, 2023 1:18 pm

Rsync restoring a compressed version

Post by szymon1051 »

I found this website https://www.pragmaticlinux.com/2021/05/ ... -in-linux/
With this you can archive data

Code: Select all

sudo rsync -a --info=progress2 --exclude="lost+found" --exclude=".cache" [SOURCE DIR]/ [DESTINATION DIR]/
For home it will be

Code: Select all

sudo rsync -a --info=progress2 --exclude="lost+found" --exclude=".cache" /home/ /mnt/usbdrive/
To restore, you only need to reverse the source and destination.

Code: Select all

sudo rsync -a --info=progress2 --exclude="lost+found" --exclude=".cache" /mnt/usbdrive/ /home/
Why do I need --exclude when restoring?
Should it be /home/ or /home and /mnt/usbdrive/ or /mnt/usddrive?


How does -a, --archive work?
How does it differ from simple copying?



According to the manual
https://www.man7.org/linux/man-pages/man1/rsync.1.html
there is an option for compression
--compress, -z compress file data during the transfer


All I need to do is add the -z flag to create copies, i.e. I will have -az and it will be archived and compressed?
Optionally, I'll add the -v flag to make it more verbose.

Code: Select all

sudo rsnc -az  /home/ /mnt/usbdrive/
To restore such an archive to the target location, i.e. /home, all I need to do is add the -z flag, so I will have -az in the restore process?

Code: Select all

sudo rsnc -az /mnt/usbdrive/ /home/
User avatar
SprinterDriver
Level 4
Level 4
Posts: 262
Joined: Sun Jan 25, 2015 3:35 pm
Location: Norway

Re: Rsync restoring a compressed version

Post by SprinterDriver »

szymon1051 wrote: Sun Jun 09, 2024 1:03 pmWhy do I need --exclude when restoring?
Because temporary files and deleted files are probably not worth restoring.

szymon1051 wrote: Sun Jun 09, 2024 1:03 pmHow does -a, --archive work?
How does it differ from simple copying?
Because without, you'll lose the file last modified time, it will be set to the time you copied the file instead. Just run man rsync to see what each option means.
So I got this bright idea. But when I tried to grab the light bulb, I did not hurt my hands as expected from a warm bulb, because it turned out to be one of those LED bulbs.
User avatar
AndyMH
Level 21
Level 21
Posts: 13966
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Rsync restoring a compressed version

Post by AndyMH »

szymon1051 wrote: Sun Jun 09, 2024 1:03 pm there is an option for compression
--compress, -z compress file data during the transfer

All I need to do is add the -z flag to create copies, i.e. I will have -az and it will be archived and compressed?
No, it will not be compressed, the key words being "during the transfer".
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
dollyp
Level 3
Level 3
Posts: 140
Joined: Sun Jul 24, 2011 4:50 pm

Re: Rsync restoring a compressed version

Post by dollyp »

szymon1051 wrote: Sun Jun 09, 2024 1:03 pm Should it be /home/ or /home and /mnt/usbdrive/ or /mnt/usddrive?
As I understand it you have to add a trailing / to both source and destination in order to copy the whole directory structure and files and not just the files in the source directory, i.e. recursive.

I also use the --delete argument so that rsync deletes files in the destination that I have deleted from the source. Saves destination from being cluttered with every file I've created but deleted.
Post Reply

Return to “Software & Applications”