How to automate the backup of the database

12
Avatar 488
Had
7

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.

█ ННП █ Самый надёжный и недорогой хостинг в России - https://clck.ru/MDrmD
Avatar 142
#1

deleted

10 times removed

Avatar 14
#2

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

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

Make CIS great again... https://hip-hosting.com (https://hip-hosting.com) VDS/VPS с быстрой установкой (Польша, Финляндия). Telegram: @frct1 (https://t.me/frct1)
DV 643
#3

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 хостинг (http://clck.ru/0u97l) Нет нерешаемых задач (/ru/forum/806725) | Перенос сайтов на Drupal 7 с любых CMS. (/ru/forum/comment/10504844)
Avatar 197
#4

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 / mysite.ru

# 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
$ FTP -n $ FTPS << END_SCRIPT
quote USER $ FTPU
quote PASS $ FTPP
mkdir $ daten
cd $ daten
put $ DUMPFILE1
put $ DUMPFILE2
quit
END_SCRIPT

# Go to the folder with the backup
cd $ 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
M5 212
M25
#5

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

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

Had:
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

D8 128
#6

googly plink, but on the hosting should have access to ssh

Avatar 200
#7
M25:
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 (https://mirhosting.com/paas)
Avatar 488
Had
#8
Aisamiery:
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.

M25:
I backed up and send to email.

They are there already archived database when downloading.

2oll

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.

Avatar 450
#9

And what about the advertised begete no functional backup?

EuroHoster.org (https://eurohoster.org/link.php?id=42) - территория быстрых серверов. Intel Xeon E-2236 (6 ядер, 12 потоков, 3.40 GHz, 4.80GHz Turbo) Intel Xeon E-2278 (8 ядер, 16 потоков, 3.40 GHz, 5.00GHz Turbo)
Avatar 150
Had:
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:

http://evgenius.com/z/dbbackup.7z

create an online (or technical subdomain that beget you provide - login.beget.tech) 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'] = '1.1.1.1') die ();

and of course correct 1.1.1.1 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:

https://www.php.net/manual/ru/function.date.php

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 😎

12

To post a new comment, please log in or register