Upload files to ''
This commit is contained in:
57
GiteaBackup.sh
Normal file
57
GiteaBackup.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#################################
|
||||
#
|
||||
#Make sure lftp is installed
|
||||
#if lftp has problem connecting try adding the folowing to /etc/lftp.conf
|
||||
# set ssl:verify-certificate no
|
||||
# set ftp:ssl-allow false
|
||||
#
|
||||
##################################
|
||||
## Automation
|
||||
## add to /etc/crontab and restart cron (/etc/init.d/cron restart)
|
||||
#30 4 * * * root /bin/sh /root/GiteaBackup.sh
|
||||
##################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##Configuration
|
||||
|
||||
RMDAYS=14 #Days until first backup gets removed
|
||||
FTPSERVER=<RemoteServer> #Addres of FTP Server
|
||||
FTPUSER=<RemoteUser> #User for FTP Server
|
||||
DBNAME=<DBName> #Database that will be backed up
|
||||
DBPASS=<DBPassword>
|
||||
BACKUPFROM="/etc/nginx/ /opt/ /etc/gitea/ /home/git/ /root/ /var/www /etc/lftp.conf /etc/crontab /home/nimda /usr/share/cockpit /etc/ssh /etc/pam.d/cockpit" #Folders and files that will be backed
|
||||
SITENAME=<SiteName> #Name of site that will be backed up
|
||||
|
||||
##Setting Static Variables
|
||||
LFTP=/usr/bin/lftp # Path to binary
|
||||
TMPDIR=$(mktemp -d) # Your archives are here
|
||||
TODAY=$(date --iso) # Today's date like YYYY-MM-DD
|
||||
RMDATE=$(date --iso -d "$RMDAYS days ago") # TODAY minus X days - too old files
|
||||
|
||||
|
||||
|
||||
|
||||
##Run
|
||||
|
||||
|
||||
cd $TMPDIR
|
||||
#mysqldump -u root -p$ "$DBNAME" > "$TMPDIR"/"$SITENAME".sql #Dumping DB
|
||||
mysqldump -u root "$DBNAME" --password="$DBPASS" --default-character-set=utf8 > "$TMPDIR"/"$SITENAME".sql #Dumping DB
|
||||
|
||||
tar -zcf /"$TMPDIR"/"$SITENAME".tar.gz $BACKUPFROM #Create tar File
|
||||
|
||||
#Uploading and remove first backup on FTP
|
||||
$LFTP << EOF
|
||||
open -u ${FTPUSER}, sftp://${FTPSERVER}
|
||||
mkdir -p ${SITENAME}/${TODAY}
|
||||
cd ${SITENAME}/${TODAY}
|
||||
mput -E ${TMPDIR}/*
|
||||
cd ..
|
||||
rm -rf ${RMDATE}
|
||||
bye
|
||||
EOF
|
||||
|
||||
rm -r "$TMPDIR" #Deletes Temp Folder
|
||||
75
Nextcloud-Backup.sh
Normal file
75
Nextcloud-Backup.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
###############################################################################
|
||||
#
|
||||
# NEXTCLOUD BackupTool
|
||||
#
|
||||
# @author: Bram Prieshof
|
||||
#
|
||||
###############################################################################
|
||||
## Automation
|
||||
##
|
||||
## Edit contab (nano /etc/crontab)
|
||||
## Restart crontab (/etc/init.d/cron restart)
|
||||
##
|
||||
#################################################################################
|
||||
|
||||
|
||||
##Configuration
|
||||
|
||||
RMDAYS=14 #Days until first backup gets removed
|
||||
DOMC=01 #Day of month for monthly removal of deleted files
|
||||
REMOTESERVER=<Remote-Server> #Addres of Backup Server
|
||||
REMOTEUSER=<user> #User for Backup Server
|
||||
|
||||
SYSNAME=<systemName> #System Hostname
|
||||
BACKUPFROM="/etc/nginx/ /etc/php/ /etc/mysql/ /etc/crontab /opt/ /etc/loolwsd/" #Folders and files that will be backed
|
||||
DBPASS='<MSQLRootPW>' #MySQL Root password (syntax '<MSQLRootPW>')
|
||||
|
||||
|
||||
DBNAME=<DBName> #Database that will be backed up
|
||||
ILOCATION="/var/www/<domain>" #Nextcloud instance Location
|
||||
SITENAME=<Instance name> #Name of instance that will be backed up
|
||||
|
||||
|
||||
#######################################################################
|
||||
## ##
|
||||
## PLEASE DO NOT MAKE CHANGES UNDER HERE ##
|
||||
## ##
|
||||
#######################################################################
|
||||
|
||||
|
||||
##Setting Static Variables
|
||||
LFTP=/usr/bin/lftp #Path to binary
|
||||
TMPDIR=$(mktemp -d) #Your archives are here
|
||||
SENDDIR=$(mktemp -d) #Sends everything in this folder to ftp
|
||||
TODAY=$(date --iso) #Today's date like YYYY-MM-DD
|
||||
RMDATE=$(date --iso -d "$RMDAYS days ago") #TODAY minus X days - too old files
|
||||
DOM=`date '+%d'` #Day of the month
|
||||
|
||||
##Run
|
||||
#Rsyncing instance files
|
||||
rsync -e 'ssh -p23' -a ${ILOCATION} "$REMOTEUSER"@"$REMOTESERVER":"$SITENAME"
|
||||
|
||||
#Dumping DataBase
|
||||
mysqldump -u root "$DBNAME" --password="$DBPASS" --default-character-set=utf8 > "$SENDDIR"/"$SITENAME".sql #Dumping DB
|
||||
|
||||
#Taring Config files and DB
|
||||
tar --exclude='/opt/collaboraoffice6.0' --exclude='/opt/lool' -zcf /"$SENDDIR"/"$SYSNAME"-Config-DB.tar.gz $BACKUPFROM #Create tar File
|
||||
|
||||
#Uploading and remove first config-db backup on SFTP
|
||||
$LFTP << EOF
|
||||
open -u ${REMOTEUSER}, sftp://${REMOTESERVER}
|
||||
mkdir -p ${SYSNAME}/${TODAY}
|
||||
cd ${SYSNAME}/${TODAY}
|
||||
mput -E ${SENDDIR}/*
|
||||
cd ..
|
||||
rm -rf ${RMDATE}
|
||||
bye
|
||||
EOF
|
||||
|
||||
#Checking and running monthly backup to SFTP
|
||||
if [ $DOM == $DOMC ]; then
|
||||
rsync -e 'ssh -p23' --delete -a ${ILOCATION} "$REMOTEUSER"@"$REMOTESERVER":"$SITENAME"
|
||||
fi
|
||||
|
||||
#Deletes Temp Folder
|
||||
rm -r "$TMPDIR" && rm -r "$SENDDIR"
|
||||
137
WP_Ftp-Backup.sh
Normal file
137
WP_Ftp-Backup.sh
Normal file
@@ -0,0 +1,137 @@
|
||||
###############################################################################
|
||||
#
|
||||
#Make sure that install-backup-tools.sh has ran for this site configureation
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
## Automation
|
||||
##
|
||||
## Edit contab (nano /etc/crontab)
|
||||
## Restart crontab (/etc/init.d/cron restart)
|
||||
##
|
||||
#################################################################################
|
||||
## SFTP
|
||||
## if sftp is used comment line "FTPPW" and
|
||||
## make sure ssh connection can be made with root's ssh key
|
||||
##
|
||||
#################################################################################
|
||||
|
||||
|
||||
##Configuration
|
||||
|
||||
RMDAYS=14 #Days until first backup gets removed
|
||||
DOMC=01 #Day of month for monthly backups
|
||||
BACKUPSERVICE=ftp #transfer prtocal use ftp or sftp
|
||||
REMOTESERVER=<Remote-Server> #Addres of FTP Server
|
||||
REMOTEUSER=<user> #User for FTP Server
|
||||
FTPPW=<Password> #Password for FTP Server ##Comment out if SFTP is used##
|
||||
REMOTEPATH=/Rftp/backup/vps #Path were backup wil be stored on FTP and a site sub-folder will be made
|
||||
|
||||
DOMAIN=<domain.com> #DomainName
|
||||
SITENAME=<name> #Name of site that will be backed up
|
||||
BACKUPFROM="/etc/nginx/ /etc/apache2/ /etc/php/ /etc/mysql/ /etc/crontab /opt/ /var/www/"$DOMAIN"/" #Folders and files that will be backed
|
||||
|
||||
DBNAME=<DBName> #Database that will be backed up
|
||||
DBPASS='<MSQLRootPW>' #MySQL Root password (syntax '<MSQLRootPW>')
|
||||
|
||||
ENABLEUPDATE=1 #set to 1 to enable or to 0 to disable wordpress updates
|
||||
|
||||
|
||||
#############################################################################
|
||||
## #
|
||||
## PLEASE DO NOT MAKE CHANGES UNDER HERE #
|
||||
## #
|
||||
#############################################################################
|
||||
|
||||
|
||||
##Setting Static Variables
|
||||
LFTP=/usr/bin/lftp #Path to binary
|
||||
TMPDIR=$(mktemp -d) #Your archives are here
|
||||
SENDDIR=$(mktemp -d) #Sends everything in this folder to ftp
|
||||
TODAY=$(date --iso) #Today's date like YYYY-MM-DD
|
||||
RMDATE=$(date --iso -d "$RMDAYS days ago") #TODAY minus X days - too old files
|
||||
DOM=`date '+%d'` #Day of the month
|
||||
|
||||
|
||||
|
||||
##Run
|
||||
|
||||
#Creating AI1M file
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html plugin update all-in-one-wp-migration-unlimited-extension
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html plugin update all-in-one-wp-migration
|
||||
cd /var/www/"$DOMAIN"/html
|
||||
sudo -u www-data wp ai1wm backup
|
||||
mv /var/www/"$DOMAIN"/html/wp-content/ai1wm-backups/*.wpress "$TMPDIR"
|
||||
cd $TMPDIR
|
||||
tar -zcf /"$SENDDIR"/"$SITENAME"-ai1wm.tar.gz -C $TMPDIR *.wpress #Create ai1wm tar File
|
||||
rm -f /"$TMPDIR"/*.wpress
|
||||
|
||||
#Dumping DataBase
|
||||
mysqldump -u root "$DBNAME" --password="$DBPASS" --default-character-set=utf8 > "$TMPDIR"/"$SITENAME".sql #Dumping DB
|
||||
tar -zcf /"$SENDDIR"/"$SITENAME"-DB.tar.gz -C "$TMPDIR" *.sql #Create tar File
|
||||
|
||||
#Taring systemFiles files
|
||||
tar -zcf /"$SENDDIR"/"$SITENAME"-Files.tar.gz $BACKUPFROM #Create tar File
|
||||
|
||||
if [ $BACKUPSERVICE = ftp ]; then
|
||||
#Uploading and remove first backup on FTP
|
||||
$LFTP << EOF
|
||||
open ${REMOTEUSER}:${FTPPW}@${REMOTESERVER}
|
||||
cd "${REMOTEPATH}"
|
||||
mkdir -p ${SITENAME}/${TODAY}
|
||||
cd ${SITENAME}/${TODAY}
|
||||
mput -E ${SENDDIR}/*
|
||||
cd ..
|
||||
rm -rf ${RMDATE}
|
||||
bye
|
||||
EOF
|
||||
|
||||
#Checking and running monthly backup to FTP
|
||||
if [ $DOM == $DOMC ]; then
|
||||
$LFTP << EOF
|
||||
open ${REMOTEUSER}:${FTPPW}@${REMOTESERVER}
|
||||
cd "${REMOTEPATH}"
|
||||
rm -rf ${SITENAME}/Monthly/
|
||||
mkdir -p ${SITENAME}/Monthly/
|
||||
cd ${SITENAME}/Monthly/
|
||||
mput -E ${SENDDIR}/*
|
||||
bye
|
||||
EOF
|
||||
fi
|
||||
elif [ $BACKUPSERVICE = sftp ]; then
|
||||
#Uploading and remove first backup on SFTP
|
||||
$LFTP << EOF
|
||||
open -u ${REMOTEUSER}, sftp://${REMOTESERVER}
|
||||
cd "${REMOTEPATH}"
|
||||
mkdir -p ${SITENAME}/${TODAY}
|
||||
cd ${SITENAME}/${TODAY}
|
||||
mput -E ${SENDDIR}/*
|
||||
cd ..
|
||||
rm -rf ${RMDATE}
|
||||
bye
|
||||
EOF
|
||||
|
||||
#Checking and running monthly backup to SFTP
|
||||
if [ $DOM == $DOMC ]; then
|
||||
$LFTP << EOF
|
||||
open -u ${REMOTEUSER}, sftp://${REMOTESERVER}
|
||||
cd "${REMOTEPATH}"
|
||||
rm -rf ${SITENAME}/Monthly/
|
||||
mkdir -p ${SITENAME}/Monthly/
|
||||
cd ${SITENAME}/Monthly/
|
||||
mput -E ${SENDDIR}/*
|
||||
bye
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
#Deletes Temp Folder
|
||||
rm -r "$TMPDIR" && rm -r "$SENDDIR"
|
||||
|
||||
#Wordpress updates
|
||||
if [ $ENABLEUPDATE = 1 ]; then
|
||||
wp cli update
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html core update
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html plugin update --all
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html theme update --all
|
||||
fi
|
||||
67
WP_Hourly_local-Backup.sh
Normal file
67
WP_Hourly_local-Backup.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
###############################################################################
|
||||
#Hourly wordpress backup script
|
||||
#
|
||||
#Make sure that install-backup-tools.sh has ran for this site configureation
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
## Automation
|
||||
##
|
||||
## Edit contab (nano /etc/crontab)
|
||||
## Restart crontab (/etc/init.d/cron restart)
|
||||
##
|
||||
#################################################################################
|
||||
|
||||
|
||||
##Configuration
|
||||
|
||||
DOMAIN=<domain.com> #DomainName
|
||||
SITENAME=<name> #Name of site that will be backed up
|
||||
BACKUPFROM="/etc/nginx/ /etc/apache2/ /etc/php/ /etc/mysql/ /etc/crontab /var/www/"$DOMAIN"/" #Folders and files that will be backed
|
||||
BACKUPTO="/backup" #Please enter path without tailing slash
|
||||
DBNAME=<DBName> #Database that will be backed up
|
||||
DBPASS='<MSQLRootPW>' #MySQL Root password (syntax '<MSQLRootPW>')
|
||||
|
||||
SYSBACKUP=1 #Enable or disable file backups
|
||||
BDBACKUP=1 #Enable or disable database backups
|
||||
AI1MBACKUP=1 #Enable or disable Ai1M backups
|
||||
|
||||
|
||||
#############################################################################
|
||||
## #
|
||||
## PLEASE DO NOT MAKE CHANGES UNDER HERE #
|
||||
## #
|
||||
#############################################################################
|
||||
|
||||
|
||||
##Setting Static Variables
|
||||
LFTP=/usr/bin/lftp #Path to binary
|
||||
TMPDIR=$(mktemp -d) #Your archives are here
|
||||
BACKUPTO=${BACKUPTO}/$(date +"%H") #Sends everything in this folder to ftp
|
||||
|
||||
|
||||
mkdir -p ${BACKUPTO}
|
||||
|
||||
#AI1M backup
|
||||
if [ $AI1MBACKUP = 1 ]; then
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html plugin update all-in-one-wp-migration-unlimited-extension
|
||||
sudo -u www-data wp --path=/var/www/"$DOMAIN"/html plugin update all-in-one-wp-migration
|
||||
cd /var/www/"$DOMAIN"/html
|
||||
sudo -u www-data wp ai1wm backup
|
||||
mv /var/www/"$DOMAIN"/html/wp-content/ai1wm-backups/*.wpress "$TMPDIR"
|
||||
cd $TMPDIR
|
||||
tar -zcf /"$BACKUPTO"/"$SITENAME"-ai1wm.tar.gz -C $TMPDIR *.wpress #Create ai1wm tar File
|
||||
rm -f /"$TMPDIR"/*.wpress
|
||||
fi
|
||||
|
||||
#Database Backup
|
||||
if [ $BDBACKUP = 1 ]; then
|
||||
mysqldump -u root "$DBNAME" --password="$DBPASS" > "$TMPDIR"/"$SITENAME".sql #Dumping DB
|
||||
tar -zcf /"$BACKUPTO"/"$SITENAME"-DB.tar.gz -C "$TMPDIR" *.sql #Create tar File
|
||||
fi
|
||||
|
||||
if [ $SYSBACKUP = 1 ]; then
|
||||
tar -zcf /"$BACKUPTO"/"$SITENAME"-Files.tar.gz $BACKUPFROM #Create tar File
|
||||
fi
|
||||
|
||||
rm -r "$TMPDIR"
|
||||
49
install-backup-tools.sh
Normal file
49
install-backup-tools.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
apt update
|
||||
|
||||
echo "Domain without www:"
|
||||
read domain
|
||||
|
||||
while true; do
|
||||
read -p "Is this the first run on this server? -> yes/no?" yn
|
||||
case $yn in
|
||||
[Yy]* ) fr=1
|
||||
break;;
|
||||
[Nn]* ) fr=0
|
||||
break;;
|
||||
* ) echo "Choose yes of no.";;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $fr = 1 ]; then
|
||||
############
|
||||
# lftp #
|
||||
############
|
||||
|
||||
apt install -y lftp
|
||||
sed -i -e '$a set ssl:verify-certificate no' /etc/lftp.conf
|
||||
sed -i -e '$a set ftp:ssl-allow false' /etc/lftp.conf
|
||||
|
||||
##############
|
||||
# wp-cli #
|
||||
##############
|
||||
cd /opt
|
||||
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /opt/wp-cli.phar
|
||||
wget https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash -O /opt/wp-completion.bash
|
||||
chmod +x /opt/wp-cli.phar
|
||||
mv /opt/wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
sed -i -e '$a source /opt/wp-completion.bash' ~/.bash_profile
|
||||
source ~/.bash_profile
|
||||
sed -i "\$a30 3 * * * root /bin/sh /opt/backup.sh >/dev/null 2>&1" /etc/crontab
|
||||
systemctl restart cron
|
||||
wget https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Backup/raw/branch/master/WP_Ftp-Backup.sh -O /opt/backup.sh
|
||||
chmod +x /opt/backup.sh
|
||||
fi
|
||||
|
||||
wp cli update
|
||||
sudo -u www-data wp --path=/var/www/"$domain"/html plugin install all-in-one-wp-migration --activate
|
||||
sudo -u www-data wp --path=/var/www/"$domain"/html plugin install https://git.ictmaatwerk.com/downloads/wp/migrate.zip --activate
|
||||
sudo -u www-data wp --path=/var/www/"$domain"/html plugin update --all
|
||||
sudo -u www-data wp --path=/var/www/"$domain"/html core update
|
||||
|
||||
echo "The backup script is placed in /opt/backup.sh"
|
||||
Reference in New Issue
Block a user