Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet212/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   208   209   210   211   212   213   214   215   ...   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)

[
 158 
]
Next, let's make sure 
rsync
 is actually installed, and install it if it's not:
If [ ! -f /usr/bin/rsync ]; then 
    sudo apt install -y rsync 
fi 
Here, we're simply checking to see whether 
rsync
 is 
not
 installed. If it's not, we'll 
install it via 
apt
. This is similar to how we checked for the existence of 
apache2
 earlier 
in this chapter.
Now, we add the final line:
rsync -avb --delete --backup-dir=/backup/incremental/$CURDATE /src /
target
You can definitely see the magic of variables in Bash now, if you haven't already. 
We're including 
$CURDATE
 in our command, which is set to whatever the current date 
actually is. When we add it all together, our script looks like this:
#/bin/bash
CURDATE=$(date +%m-%d-%Y)
if [ ! -f /usr/bin/rsync ]; then 
    sudo apt install -y rsync 
fi
rsync -avb --delete --backup-dir=/backup/incremental/$CURDATE /src /
target 
This script, when run, will run an 
rsync
 job that will copy the contents from 
/src
 
to 
/target
. (Be sure to change these directories to match the source directory you 
want to back up and the target where you want to copy it to.) The beauty of this is 
that 
/target
 can be an external hard drive or network share. So, in a nutshell, you 
can automate a nightly backup. This backup, since we used the 
-b
 option along with 
--backup-dir
, will allow you to retrieve previous versions of a file from the 
/backup/
incremental
 directory. Feel free to get creative here as far as where to place previous 
file versions and where to send the backup.
Of course, don't forget to mark the script as executable, assuming it was saved with a 
name like 
backup.sh
:
chmod +x backup.sh


Chapter 6

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   208   209   210   211   212   213   214   215   ...   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