Tutorial: How to Perform Backups and Crontab Scheduling on Linux and Unix
Lab 0x06 - Linux Backups, Cron, and Scripting
Overview
This lab should expose the student to backups using tar and chronological tables using scripts. Additional investigation into tar, network backup transfer, and encryption are encouraged.
Create your first backup script:
date +%Y%m%d.%H%M
vi sys_backup.sh
#!/bin/bash
# Comment/NAME 20200422.2000hrs
# Backup script
var_date=`date +%Y%m%d.%H%M`
tar czf /opt/backups/Daily-$var_date.tar.gz /etc /var/www /var/log
chmod 775 sys_backup.sh
ll backups/
ll
Change the files to their final names:
cp sys_backup.sh sys_backup_weekly.sh
mv sys_backup.sh sys_backup_daily.sh
Change the weekly backup to reflect the proper name:
vi sys_backup_weekly.sh
#!/bin/bash
# Comment/NAME 20200422.2000hrs
# Backup script
var_date=`date +%Y%m%d.%H%M`
tar czf /opt/backups/Weekly-$var_date.tar.gz /etc /var/www /var/log
Configure the chronological table:
vi /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
00 00 * * 1-6 root /opt/sys_backup_daily.sh
00 00 * * 7 root /opt/sys_backup_weekly.sh
Thank you for dropping by!
Please join me:
https://www.youtube.com/PaulWPoteete
https://www.twitter.com/PaulWPoteete
https://www.linkedin.com/in/PaulWPoteete
Tutorial: How to Perform Backups and Crontab Scheduling on Linux and Unix
Видео Tutorial: How to Perform Backups and Crontab Scheduling on Linux and Unix канала The Expat Professor
Overview
This lab should expose the student to backups using tar and chronological tables using scripts. Additional investigation into tar, network backup transfer, and encryption are encouraged.
Create your first backup script:
date +%Y%m%d.%H%M
vi sys_backup.sh
#!/bin/bash
# Comment/NAME 20200422.2000hrs
# Backup script
var_date=`date +%Y%m%d.%H%M`
tar czf /opt/backups/Daily-$var_date.tar.gz /etc /var/www /var/log
chmod 775 sys_backup.sh
ll backups/
ll
Change the files to their final names:
cp sys_backup.sh sys_backup_weekly.sh
mv sys_backup.sh sys_backup_daily.sh
Change the weekly backup to reflect the proper name:
vi sys_backup_weekly.sh
#!/bin/bash
# Comment/NAME 20200422.2000hrs
# Backup script
var_date=`date +%Y%m%d.%H%M`
tar czf /opt/backups/Weekly-$var_date.tar.gz /etc /var/www /var/log
Configure the chronological table:
vi /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
00 00 * * 1-6 root /opt/sys_backup_daily.sh
00 00 * * 7 root /opt/sys_backup_weekly.sh
Thank you for dropping by!
Please join me:
https://www.youtube.com/PaulWPoteete
https://www.twitter.com/PaulWPoteete
https://www.linkedin.com/in/PaulWPoteete
Tutorial: How to Perform Backups and Crontab Scheduling on Linux and Unix
Видео Tutorial: How to Perform Backups and Crontab Scheduling on Linux and Unix канала The Expat Professor
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Linux Backup with TAR and Cron Jobs](https://i.ytimg.com/vi/hGqjM9Wz-pU/default.jpg)
![Automate Backup in Linux Using RSYNC & Crontab | Backup Data On Remote Server Using RSYNC](https://i.ytimg.com/vi/sS5Y-rSaf-c/default.jpg)
![Write Your Own Bash Scripts for Automation [Tutorial]](https://i.ytimg.com/vi/PPQ8m8xQAs8/default.jpg)
![Cron Jobs For Beginners | Linux Task Scheduling](https://i.ytimg.com/vi/v952m13p-b4/default.jpg)
![Easy rsync Backup with tar and cron (daily, weekly, monthly)](https://i.ytimg.com/vi/z35ZPELo5_Y/default.jpg)
![Task Scheduling in Linux - CronTab Command and How to Create/Use a Cron Job | 2021 Tutorial](https://i.ytimg.com/vi/owLj5Vk_LVI/default.jpg)
![Network Automation: Schedule Cisco config backups with kron and archive](https://i.ytimg.com/vi/-y-HUJOI8i4/default.jpg)
![Unix/Linux Essentials - Backing Up Files & Directories Using Tar](https://i.ytimg.com/vi/b7WmRXzCCSw/default.jpg)
![Raspberry Pi Workshop - Chapter 3 - Scheduling with Cron Jobs](https://i.ytimg.com/vi/rErAOjACT6w/default.jpg)
![Introduction to Linux and Basic Linux Commands for Beginners](https://i.ytimg.com/vi/IVquJh3DXUA/default.jpg)
![Linux Archive, Backup And Compress Utility (tar, Gzip, Bzip2, 7zip, Zip etc.) Part - 1](https://i.ytimg.com/vi/pbclwytrH_k/default.jpg)
![Linux Training - HOW TO Create Users and Groups in Linux](https://i.ytimg.com/vi/-OzmiIPOTxI/default.jpg)
![How to backup and restore Crontab in Linux](https://i.ytimg.com/vi/hiTQuwINvfw/default.jpg)
![How to schedule backup Job for MariaDB or MySQL by using crontab - MariaDB Admin Tutorial](https://i.ytimg.com/vi/Rk8p7duZtJY/default.jpg)
![Creating a Scheduled backup on Linux](https://i.ytimg.com/vi/TElD7ycD-tA/default.jpg)
![Hard and Soft Links in Linux](https://i.ytimg.com/vi/kYonC93SvpE/default.jpg)
![Make an Incremental Backup Script with Bash!](https://i.ytimg.com/vi/m8gN8iCWLdI/default.jpg)
![How to schedule a Cron Job to run a script on Ubuntu 16.04](https://i.ytimg.com/vi/CIVI-DIzCFk/default.jpg)
![How to create,extract,compress tar files in linux ubuntu [ Explained ]](https://i.ytimg.com/vi/nxor30XUqnU/default.jpg)
![How to schedule job using cron tab in Linux](https://i.ytimg.com/vi/7yTUEDABPKU/default.jpg)