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

Cron

Cron is the daemon that can be used to schedule tasks according to time, day of the month,...

Centos 6 Webserver

In this article we will install some software that is useful on a webserver based on...

Backing up VPS from the inside

This guide will show you how to backup your vsp/container "from the inside vps". First of...

!!Actual Linux KB located : wiki.vpsget.com ***

Linux kb/wiki moved to opur wiki pages and all new articled publiched here:...

Dovecot /postfix with Roundcube WebUI

Following guide was tested on CentOS 6. Install epel repository: wget...