Backup script sample

#!/bin/bash
echo "packing files in progress..."
tar -cf /home/backup/root_lib-$(date +%H.%M-%d-%m-%y).tar /root/install.log /lib
dd if=/dev/vg-virt/kvm110_img | gzip | dd of=/home/backup/kvm110-$(date +%H:%M-%d-%m-%y).gz bs=4096
find /home/backup/ -type f -mtime +6 -exec rm {} \;
echo "completed"

Strings:

1 Describes the language
2 Shows message "packing files in progress..." on the screen
3 Packing file /root/install.log and folder /lib in archive /home/backup/root_lib-19.10-19-06-13.tar
4 Packing file of virtual machine /dev/vg-virt/kvm110_img which is in use without suspending the VM. Archive name format: kvm110-19.10-19-06-13.gz
5 Find and delete files older than 6 days in folder /home/backup/
6 Shows message "completed" on the screen

So script can be placed in crontab to be scheduled 2 times a week and it will store 2 actual backups and remove older ones.

 

Was this answer helpful?

 Print this Article

Also Read

Forward (redirect/nat) traffic with iptables

If you want to redirect/nat some traffic to IP 2.2.2.2 via IP 1.1.1.1, it simply can be done...

Changing mac address in VMware

In Centos: 1. Edit old mac HWADDR=XX:XX:XX:XX:XX:XX in the file...

Web server

In this guide we will create our own web server on Centos 6.  We will use Apache...

Autorun in Linux

To set a script to start at boot in CentOS, add it into /etc/rc3.d/S99local. For example:...

nginx

How to install nginx on Centos Add nginx repo first. To add it, create the file...