-2

I am not a programmer at all, however I am teaching myself bash scripting and I have a need for a backup script to backup my VMs (I am using KVM/QEMU). I know that you can do snapshots but I need something more permanent a hard copy of the VM if you will and be able to put these on my ZFS Storage system. So I was thinking to write a backup script that runs via cron once a week or so. The file is of course qcow2 or whatever file system is chosen. So far I have a good start on the script.

Some parts of this script has been borrowed from another author

### kvm-backup.0.0.1 ###

#!/bin/bash
# Get the date #
BACKUPTIME=`date +%b-%d-%y`  # Affixing the date
# Create the backup file and cp to Destination for backups #
DESTINATION=/mnt/backups/backup-$BACKUPTIME.tar.gz
# Need to define the source folder #
SOURCEFOLDER=/mnt/VMs/

# create backup now #
tar -cpzf $DESTINATION $SOURCEFOLDER

### Right here I need a progress bar but I am not sure how put it all together I know the code above will have to be fitted in to one of the progress bar scripts. I am just not smart enough to put it all together. ###

Could someone help me out a little bit, Thanks, Michael

0

1 Answer 1

0

You could use pv

tar cpzf - $DESTINATION -P | pv -s $(du -sb $DESTINATION | awk '{print $1}') | gzip > $BACKUPTIME.tar.gz
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.