Difference between revisions of "Backup script sample"

From vpsget wiki
Jump to: navigation, search
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
  #!/bin/bash
+
  <span style="color:#c0c0c0">1</span>#!/bin/bash
  echo "packing files in progress..."
+
  <span style="color:#c0c0c0">2</span>echo "packing files in progress..."
 +
<span style="color:#c0c0c0">3</span>tar -cf /home/backup/root_lib-$(date +%H.%M-%d-%m-%y).tar /root/install.log /lib
 +
<span style="color:#c0c0c0">4</span>dd if=/dev/vg-virt/kvm110_img | gzip | dd of=/home/backup/kvm110-$(date +%H:%M-%d-%m-%y).gz bs=4096
 +
<span style="color:#c0c0c0">5</span>find /home/backup/ -type f -mtime +6 -exec rm {} \;
 +
<span style="color:#c0c0c0">6</span>echo "completed"
  
<span style="color:#c0c0c0">1</span>tar -cf /home/backup/root_lib-$(date +%H:%M-%d-%m-%y).tar /root/install.log /lib
+
Strings:
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 {} \;
+
1 Describes the language<br>
echo "completed"
+
2 Shows message "packing files in progress..." on the screen<br/>
</pre>
+
3 Packing file ''/root/install.log'' and folder ''/lib'' in archive /home/backup/'''root_lib-19.10-19-06-13.tar'''<br/>
Strings:<br/>
+
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'''<br/>
1 Describes the language
+
5 Find and delete files older than 6 days in folder ''/home/backup/''<br/>
2 Shows message "packing files in progress..." on the screen
+
6 Shows message "completed" on the screen
3
+
 
"[[Category:Linux]]"
+
So script can be placed in [http://wiki.vpsget.com/index.php/Cron crontab] to be scheduled 2 times a week and it will store 2 actual backups and remove older ones.
 +
 
 +
 
 +
 
 +
[[Category:Linux]]

Latest revision as of 11:54, 17 January 2014

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