How to automate the backup of the database

Site user since 01.04.2014

Good all. What I am tired of doing database backup site hands. Strains.

Can you please tell how to automate the backup of the database of the website.

What do you need:

Every day 3 times 18.00, 21.00, 24.00 automatically (with hosting) make a backup of the site database

on my hard disk in a folder that is at the root of the E drive. Moreover, from 21.00 to not backup

overwritten by the backup of 18.00, and so on. To, for example, I, in 00.10 Go to the folder and saw 3 backup copies of the database.

I imagine it is. I create a folder on drive E (at the root of the constant). At making backup 18.00

automatically creates a folder (the folder name - day, month and year of the backup), and in it a folder (the folder name - time backup).

Something like this. Or may otherwise better to do?

More ideally, it would be nice if every 3 days removed backups in folders that have been made earlier than 3 days.

I.e. to folders I had always 9, copy the database in the last 3 days.

Hosting Beget. It should be free of charge.

⭐ Самый лучший и надёжный хостинг -
Site user since 31.01.2008


10 times removed

Илья hip-hosting
Site user since 07.06.2019

It is good that today is Friday, not tomorrow, yesterday

And in the case: can CZK something simpler for backups?

Make CIS great again... ( ) VDS/VPS с быстрой установкой в Москве. Telegram: @hiphosting( Email:
Site user since 01.05.2010

On hosting the zipped dump created by the crown.

On the local machine (if imelos in mind) can pull a bunch of ways.

For example, the wget on the scheduler, or a ftp client.

I would, since much use Cygwin on Windows, to set up a cron and there, but at least to ssh pulled together.

VDS хостинг ( ) Нет нерешаемых задач ( ) | Перенос сайтов на Drupal 7 с любых CMS. ( )
Site user since 12.04.2015

The main difficulty - is that you want to save on disk E, it means you need to open etut folder in Internet and computer always keep on, and even ship your network domeshnyuyu and iron. And in general there is nothing supernatural, you make a bash script and put it on the crown, in the script writing team, I use something Tipo this:

#! / Bin / bash

# Set from where and where we will copy the data
BACKUP = / var / www / backups
SITE = / var / www /

# Set the backup date and create the corresponding folder
daten = `date +% Y.% m.% d-% H`
mkdir $ BACKUP / $ daten

# Make a database dump
mysqldump -u USER -pPASSWORD DATABASE | gzip> `date + $ BACKUP / $ daten / database.sql.gz`

# Navigate to the folder with the site, so as not to grab too much in the structure
cd $ SITE

# Create an archive file
tar -zcvf $ BACKUP / $ daten / files.tar.gz. > / Dev / null 2> & 1

# Send the files by FTP if it is certainly required,
# But better to store backups remotely
FTP = "$ (which ftp)"

### FTP ###
FTPD = "/"
FTPU = "ftpuser"
FTPP = "ftppassword"
FTPS = "ftphost"

### ftp ###
cd $ BACKUP / $ daten
DUMPFILE1 = files.tar.gz
DUMPFILE2 = database.sql.gz
quote USER $ FTPU
quote PASS $ FTPP
mkdir $ daten
cd $ daten

# Go to the folder with the backup

# And delete old backups (30 days)
find ./ -type d -mtime +30 -exec rm -r '{}' \; 2> / dev / null

But I really do copy on selectel in the cloud and not to his home, well, put on the crown anytime this script

Разработка проектов на Symfony, Laravel, 1C-Bitrix, UMI.CMS, OctoberCMS
Site user since 12.08.2009

Submit to dropboks, and he will fill in a folder on your hard

---------- Posted 19.06.2020 at 20:02 ----------

Something like this. Or may otherwise better to do?

I backed up and send to email. Place the computer does not take, copies are made, and then when it is turned off

► Рейтинг серверов — ТОП10 ◄
Site user since 23.03.2007

googly plink, but on the hosting should have access to ssh
Site user since 18.10.2006
Submit to dropboks, and he will fill in a folder on your hard

well, I then put owncloud and synchronize themselves. Wirth on hosting it stands without any problems.

Андрей Нестеренко, MIRhosting Облачная платформа для DevOps (
Site user since 01.04.2014
The main difficulty - is that you want to save on disk E, it means you need to open that folder in the Internet

It is excluded.

I backed up and send to email.

They are there already archived database when downloading.


Option Hardy is eliminated. E also not an option.

Is it possible to somehow automate what I'm doing hands - I go to the section hosting the database, click on the "phpadmin" next to the desired database, then click "Export", then press "button" and have a zipped file is downloaded in Chrome on drive E. Here is everything you can somehow do so, to press one button to shoot? And that button is on Windows desktop.

Site user since 30.09.2009

And what about the advertised begete no functional backup? ( ) - территория быстрых серверов. Серверы, VPS, VPN от 1.50€
Евгений Крупченко
Site user since 27.09.2003
Press 1 button to shoot? And that button is on Windows desktop.

server does well he did not get through to you on drive E :, unless of course he will not be exposed to the outside in the 'Net.

why ordinary people do remain somewhere on ftp, cloud a thread anywhere that is constantly online.

but also in the task at hand nothing is unrealizable.

If the part does the server, then you need the opposite - to initiate something in their computer that would run the script on the server, and then the result was downloaded here on the same computer.

He sketched a quick skriptets:

create an online (or technical subdomain that beget you provide - a folder, throws it in the index.php

at this moment there is a small security hole.

so of course it is desirable to have a permanent ip and add to the top line of the script:

if (! $ _ SERVER [ ' REMOTE_ADDR'] = '') die ();

and of course correct to your own address. or somehow still close access stranger to this script.

otherwise hypothetically someone else can download your base 😒

then, on the desktop to create a shortcut to this script url.

and everything.

when you have to run a shortcut - the script first sdampit all the bases in the .sql files, then all that nadampil archives in archive form [date] .7z and at the end gives the file to the browser. left click to save and download [date] .7z

erase old copies excuse me, on the part of the server on your computer will not work.

also if necessary by leaps and bounds and more / minute, it is easy to correct it in the script a piece of $ date = date ( "Ymd" ); the right letters here:

Just do not use a colon for example, or something like that-nt of such things as the separator, because in Windows files with the same name are not possible.

script just tested it on begete. everything is working.

though who knows what you have there is the volume database. I tried to 150MB .sql file, and 30MB in compressed form.

if more, then there is a chance to stretch some of the limits.

In addition there is a chance of growth begetovskogo "cp" for archiving.

but if anything, you can always hit the PM is correctly shared'om without these limits all 😎


To post a new comment, please log in or register