How to take backup of domains under www directory.
just follow this,
First create a script file,
eg
vi backup-www.sh
then paste all this code in that.
#taking vmail backup
#timestamp=`date +%Y-%B-%d_%H%M%S`;
timestamp=`date +%Y-%m-%d_%H%M%S`;
host='server1';
mkdir /var/backup/www-backups
mkdir /var/backup/www-backups/$host-$timestamp
cd /var/www/
ls -lah /var/www/ > /var/backup/www-backups/$host-$timestamp/www-list
ls -lah /var/www/clients/ > /var/backup/www-backups/$host-$timestamp/clients-list
echo "Starting Backup";
echo `date`;
for dir in */
do
base=$(basename "$dir")
tar -czf "${base}.tar.gz" "$dir"
mv *.gz /var/backup/www-backups/$host-$timestamp
done
after that change the permission of newly created file.
# chmod +x backup-www.sh
then run this,
# ./backup-www.sh
your backup will start.
just follow this,
First create a script file,
eg
vi backup-www.sh
then paste all this code in that.
#taking vmail backup
#timestamp=`date +%Y-%B-%d_%H%M%S`;
timestamp=`date +%Y-%m-%d_%H%M%S`;
host='server1';
mkdir /var/backup/www-backups
mkdir /var/backup/www-backups/$host-$timestamp
cd /var/www/
ls -lah /var/www/ > /var/backup/www-backups/$host-$timestamp/www-list
ls -lah /var/www/clients/ > /var/backup/www-backups/$host-$timestamp/clients-list
echo "Starting Backup";
echo `date`;
for dir in */
do
base=$(basename "$dir")
tar -czf "${base}.tar.gz" "$dir"
mv *.gz /var/backup/www-backups/$host-$timestamp
done
after that change the permission of newly created file.
# chmod +x backup-www.sh
then run this,
# ./backup-www.sh
your backup will start.
0 comments:
Post a Comment