Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet414/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   410   411   412   413   414   415   416   417   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

[
 316 
]
Here's our first example:
sudo rsync -r /home/myuser /backup 
With that command, we're using 
rsync
 (as 
root
) to copy the contents of the 
home
 
directory for the 
myuser
 directory to a backup directory, 
/backup
 (make sure the 
target directory exists). In the example, I used the 
-r
 option, which means 
rsync
 will 
grab directories recursively as well. You should now see a copy of the 
/home/myuser
 
directory inside your 
/backup
 directory.
However, we have a bit of a problem. If you look at the permissions in the 
/backup/
myuser
 directory, you can see that everything in the target is now owned by 
root

This isn't a good thing; when you back up a user's 
home
 directory, you'll want to 
retain their permissions. In addition, you should retain as much metadata as you can, 
including things like timestamps. Let's try another variation of 
rsync
. Don't worry 
about the fact that 
/backup
 already has a copy of the 
myuser
 home directory from 
our previous backup. Let's perform the backup again, but this time, we'll use the 
-a
 
option:
sudo rsync -a /home/myuser /backup
This time, we replaced the 
-r
 option with 
-a
 (archive), which retains as much 
metadata as possible (in most cases, it should make everything an exact copy). 
What you should notice now is that the permissions within the backup match the 
permissions within the user's 
home
 directory we copied from. The timestamps of 
the files will now match as well. This works 
because whenever 
rsync
 runs, it will 
copy what's different from the last time it ran. The files from our first backup were 
already there, but the permissions were wrong. When we ran the second command, 
rsync
 only needed to copy what was different, so it applied the correct permissions 
to the files. If any new files were added to the source directory since we last ran the 
command, the new or updated files would be copied over as well.
The 
archive
 mode (the 
-a
 option that we used with the previous command) is 
actually very popular; you'll probably see it a lot during your travels. The 
-a
 option 
is actually a wrapper option that includes the following options all at the same time:
-rlptgoD 
If you're curious about what each of these options do, consult the man page for 
rsync
 
for more detailed information. In summary, the 
-r
 option copies data recursively 
(which we already know), the 
-l
 option copies symbolic links, 
-p
 preserves 
permissions, 
-g
 preserves group ownership, 
-o
 preserves the owner, and 
-D
 
preserves device files. If you put those options together, we get 
-rlptgoD
. Therefore, 
-a
 is actually equal to 
-rlptgoD
. I find 
-a
 easier to remember.


Chapter 12

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   410   411   412   413   414   415   416   417   ...   482




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish