jeudi 6 juin 2019

Need to Backup from multiple sources

I am using the script below to do daily backups. I need to add more folders to be included in the daily backup, and I would like to have them contained in the same zip file. How would this scripted be modified to backup multiple folders to the same compressed file?

#!/bin/bash
TIME=`date +%b-%d-%y`                        # This Command will read the date.
FILENAME=backup-xmltv-www-$TIME.tar.gz       # The filename including the date.
SRCDIR=/var/www/html/wp-admin                # Source backup folder.
DESDIR=/var/backups                          # Destination of backup file.
tar -cpzf $DESDIR/$FILENAME $SRCDIR

I have tried to add multiple source directories to the script, but only the last source in the list gets compressed.

SRCDIR=/var/www/html/wp-admin
SRCDIR=/var/www/html/wp-content
SRCDIR=/var/www/html/wp-includes

I have also tried to give the sources different numbers, but tar errors out to tell me to look at the tar help file.

SRCDIR1=/var/www/html/wp-admin
SRCDIR2=/var/www/html/wp-content
SRCDIR3=/var/www/html/wp-includes

Aucun commentaire:

Enregistrer un commentaire