We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
customize backup script
Re: customize backup script
do you (or anybody) still need a script that will backup all databases (and only databases) ?
Re: customize backup script
@skurudo
I updated the script - viewtopic.php?f=10&t=12338&p=49399#p49399
I added three new options:
For public_shtml it will add additional .shtml extension to backup archive file.
I updated the script - viewtopic.php?f=10&t=12338&p=49399#p49399
I added three new options:
Code: Select all
use_absolute_full_path=1
backup_public_html=1
backup_public_shtml=0
Re: customize backup script
What with databases backup? I don't see code responsible for that.
Re: customize backup script
Code: Select all
#!/bin/bash
if [ ! -d "/db-backups" ]; then
eval "mkdir /db-backups"
eval "chmod a-rwx /db-backups"
eval "chmod u=rwx /db-backups"
fi
if [ ! -d "/db-backups-archive" ]; then
eval "mkdir /db-backups-archive"
eval "chmod a-rwx /db-backups-archive"
eval "chmod u=rwx /db-backups-archive"
fi
rm /db-backups/*
cd /var/lib/mysql
for D in *; do
if [ -d "${D}" ]; then
D=${D//@002d/-}
D=${D//@002e/.}
# echo "${D}" # your processing here
mysqldump -h localhost ${D} | gzip > /db-backups/${D}_db_`date +"%Y%m%d%H"`.sql.gz
fi
done
find /db-backups-archive/* -mtime +7 -exec rm {} \;
cd /db-backups
cp * /db-backups-archive
chmod a-rwx /backup.sh
chmod u=rwx /backup.sh
chmod -R a-rwx /db-backups
chmod -R u=rw /db-backups
chmod u=rwx /db-backups
chmod -R a-rwx /db-backups-archive
chmod -R u=rw /db-backups-archive
chmod u=rwx /db-backups-archive
Re: customize backup script
where do I place this code to make it work?dpeca wrote: ↑Wed Aug 24, 2016 10:19 am* UPDATED to v0.2 *
This will backup files from ALL websites in VestaCP (each of them as separated archive), and put tar file in /backup/manual/ folder as domain.com-YYYY-MM-DD.tar(.gz)
Code: Select all
#!/bin/bash # Options: backup_folder=/backup/manual compress=0 exclude="--exclude='*/tmp/*' --exclude='*/temp/*' --exclude='*/log/*' --exclude='*/logs/*' --exclude='*/session/*' --exclude='*/sessions/*' --exclude='*/cache/*' --exclude='*/caches/*'" use_absolute_full_path=1 backup_public_html=1 backup_public_shtml=0 ################################################################################################################ # begin of script # # *** Script for backuping all VestaCP sites (only files) *** # # Created by dpeca (Predrag Damnjanovic - https://forum.vestacp.com/memberlist.php?mode=viewprofile&u=8116 ) # version: 0.2 # if [ ! -d "$backup_folder" ]; then eval "mkdir $backup_folder" fi taroptions="cfP" extension=tar date=$(date +"%Y-%m-%d") if [[ $compress -eq 1 ]]; then taroptions="czfP" extension=tar.gz fi function make_tar { folder=$1 site=$2 shtml=$3 if [[ $shtml -eq 1 ]]; then site="$site.shtml" fi if [[ $use_absolute_full_path -eq 1 ]]; then command="tar $taroptions $backup_folder/$site-$date.$extension -C / $folder $exclude" else cd $folder command="tar $taroptions $backup_folder/$site-$date.$extension . $exclude" fi # echo $command eval $command } for name in /home/* do if [ -d "$name" ]; then #echo $name/web if [ -d "$name/web" ]; then for name2 in $name/web do if [ -d "$name2" ]; then #echo $name2 for name3 in $name2/* do if [[ $backup_public_html -eq 1 ]]; then folder=$name3/public_html site=$(basename $name3) if [ -d "$folder" ]; then make_tar $folder $site 0 fi fi if [[ $backup_public_shtml -eq 1 ]]; then folder=$name3/public_shtml site=$(basename $name3) if [ -d "$folder" ]; then make_tar $folder $site 1 fi fi done fi done fi fi done