Backing up a designated folder with cyclical repetition
Hey, today I will introduce you to a small bash script, which backs up a given folder on our server at a given time or day, possibly every few minutes.
script:
1 2 3 4 5 6 7 | #!/bin/bash DATA=`date +"%b-%d-%y"` NAZWAPLIKU="backup-$DATA.tar.gz" ZRODLO="/home/linux" KDOCELOWY="/home/backup" tar -cpzf $KDOCELOWY/$NAZWAPLIKU $ZRODLO |
A catalog should be provided with the SOURCE, what we want to pack, while for KDOBELOWY we provide the path to the folder, where the copy should be. File should be given permissions 700.
Permissions:
1 | chmod 700 nazwaskryptu.sh |
If we want to, for the script to run itself, add it to the cron, (we enter in the terminal):
1 | crontab -e |
Then add it to the file, which we opened with the command above:
1 | 00 01 * * * /sciezka_do_skryptu/nazwaskryptu.sh |
Thanks to this, our script will run every day at 01:00 in the night
Related entries:
Basics of MySQL in Linux console
Installation of CSF Firewall in Debian system 11
LibreOffice is a powerful office suite and the successor to OpenOffice 5.24 sudo apt install kubuntu-desktop 21.10
Convert html file to PDF console Debian 10
Solving the problem of no matching host key type found. Their offer: ssh-rsa,ssh-dss





