M
M
motomac2017-04-17 09:05:19
MySQL
motomac, 2017-04-17 09:05:19

How to set up automatic copying of backups to a third-party FTP?

I use automysqlbackup, which stores dumps on the main server. The task is to configure the transfer of these backups to a third-party FTP. I used to use ISP Manager - this function is there by default, but recently I abandoned this panel. Installing a completely new panel like VestaCP will not work, because the server is already running, and installing this panel requires starting from scratch.
I'm looking for the easiest way to set up the overflow of backups by cron. In addition, FTP is not infinite, so old files must be deleted. Ideally, I would like some ready-made and free solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zzamzam, 2017-04-17
@motomac

Just recently I was looking for a similar solution and settled on backupninja Able
to backup databases and files on a schedule and send them to a third-party server in various ways, including rsync, rdiff, duplicity
In /etc/backup.d/ create configs like 10-db.mysql , 50 -ftp.dup
The numbers at the beginning of the file describe the order of execution in case of simultaneous launch (first dump the database, and then upload from the folder with the archive to ftp).
The file extension indicates the task type (.mysql - mysql backup, .dup - use duplicity)
The default time for backups is set in /etc/backupninja.conf

...
when = everyday at 01:00
...

It can be overridden for each individual backup at the beginning of its config
when = sundays at 02:00
when = 30th at 22
when = 30 at 22:00
when = everyday at 01            <-- the default
when = Tuesday at 05:00
when = hourly

Read more about backupninja configs here
. Duplicity itself, which I, for example, use to make backups, supports a bunch of protocols, including ftp transfer. Also supports backup rotation
. The config for duplicity looks something like this:
## Переопределяем время выполнения
when = sundays at 02:00
## Параметры, передаваемые напрямую duplicity при запуске бэкапа
## --no-encryption позволяет отключить шифрование архивов с бэкапом и получить обычный .tar.gz
#options = --no-encryption

testconnect = no
tmpdir = /tmp

[source]
include = /var/backups/mysql
include = /home/user/projects/site1
exclude = /home/user/projects/.git

[gpg]
## Ключ для симметричного шифрования. Duplicity шифрует бэкапы с помощью gpg. Должен быть указан, даже если стоит --no-encryption, хоть и не будет использоваться
password = 123

[dest]
## perform incremental backups
incremental = yes

## days of incremental backups before doing full backup again
increments = 7

## how many days of data to keep
keep = 14

## for how many full backups do we keep their later increments
keepincroffulls = all

desturl = ftp://[email protected]_backup_server/
ftp_password = backup_user_password

In backups, at first glance, not very clear files are obtained, such as
duplicity-full-signatures.20130510T160711Z.sigtar.gpg
duplicity-full.20130510T160711Z.manifest.gpg
duplicity-full.20130510T160711Z.vol1.difftar.gpg
Here you can read a little more about them
It is better to work with backups using the duplicity utility itself, but you can also pull them out manually. Manually, the minus is that incremental backups will have to be manually rolled up to full ones, when duplicity will do this automatically when specifying the recovery date.
duplicity collection-status src will give something like this
Total number of contained volumes: 3
Type of backup set:                        Time:                        Num volumes:
Full                            Mon Apr 17 00:24:46 2017                 1
Incremental                     Mon Apr 17 01:00:03 2017                 1
Incremental                     Mon Apr 17 09:53:38 2017                 1

after which you can read the contents of the archive for a specific date
duplicity list-current-files --time 2017-04-17T05:00:00 src (will show the backup Mon Apr 17 01:00:03 2017, i.e. the closest BEFORE the specified time)
and restore
duplicity restore --time 2017-04-17T05:00:00 src dst
src is where your backups are stored.
This can be either a local directory file:///var/backups//
AND ftp ftp://user:[email protected]_server//var/backups
The files themselves are stored in vol#.difftar.[tar.gz|gpg] if must be manually extracted
If encrypted, then first decrypt .gpg to get .tar.gz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question