MySQL backup archive is missing (no such file or directory)
Hi!
I have a Docker Compose config that looks something like this:
services:
mysql:
image: mysql:8
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}
MYSQL_RANDOM_ROOT_PASSWORD: true
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-password}
MYSQL_USER: ${MYSQL_USER:-app}
volumes:
- mysql_data:/var/lib/mysql
hostname: mysql.local
mysql_backup:
image: appleboy/docker-backup-database:mysql8
environment:
STORAGE_DRIVER: disk
STORAGE_BUCKET: mysql
TIME_SCHEDULE: * * * * *
DATABASE_DRIVER: mysql
DATABASE_HOST: mysql.local
DATABASE_USERNAME: ${MYSQL_USER:-app}
DATABASE_PASSWORD: ${MYSQL_PASSWORD:-password}
DATABASE_NAME: ${MYSQL_DATABASE:-app}
DATABASE_OPTS: "--no-tablespaces"
volumes:
- mysql_data_backup:/backup/mysql
volumes:
mysql_data:
mysql_data_backup:
When trying to perform a backup, an error occurs:
mysql_backup-1 | 2025/01/29 18:20:00 INFO start backup database now schedule="* * * * *"
mysql_backup-1 | ׆xaLH¿䗛ª ʺ[
¥^r[AuH]¤BewH]ވ¹¡ч45¤؊4ڴ
L烬
s疃¿⸿ť@mysqldump --version
mysql_backup-1 | mysqldump Ver 8.4.4 for Linux on x86_64 (MySQL Community Server - GPL)
mysql_backup-1 | $ mysqldump -h mysql.local -P 3306 -u app app
mysql_backup-1 | $ gzip
mysql_backup-1 |ܚmsنþ\~Ƶq
mysql_backup-1 | qŵų& )϶𝓙¹Zo
±ÿ}O�1-cψԮߞ߳쟄`þ¼𣷮ـ댱ĸ�H
W¯ÿa!,Wº,Hǫl(4QEE¦W²,Lċτİjኻଣ~s<ǃ¥ ;E©Ȣ2U¤Cp*¬ߞܕ
AសqqʼU
𩣔jv]΅;㹋e8~ڛʢ甀ծL?e¾{«ṙ~¾䗊P!ɕDΕY¸ϴr²Yª'«°P
mysql_prod_backup-1 | 川[²¢
¯C¹ݬ¡|뤭$nz<´úҼ¨[~Ɛp| ̄Xt[c'X«hc`@)hÿ~4¶
W5¨颰}𗃏qO鸆!̧/"{怐ߋ«¢eٳ·`&¼Px4·芓촯¼&b¥}(l֢=f®ꅸřF¿¢*¤hٙ¸¾ѥц´ ³+¹0okB½½HMί+Ǣaa·£EћF|?Sȃ蜍溄
ں8°Fh؉½<X7/Ğ闵 닣b/砫1¾CꖨSz8¡F'k¶ea-ڻ{¼
gǂԢAᙝ饾©Lc岰4>䄃ƍ^|ӏw峩_"
C{´g$[ҞϹ
fFؗĞٷ"±Lۑշ}d$°[Ŗ¶t
mysql_backup-1 | º܌6܅DﳼSǙ
Y6R¶.¥lɓ_`}&I
mysql_backup-1 |
¶ⷣاh®<©¦(ܽª"ࠇ¦⺡a´+㝬¯UrZdb%z¡-¥}¸eeY©뱑Œ<#k¨̤
mysql_backup-1 | R/̀'9[0ԮH¨ܭ{¬¬¬3·.ߢ` ̼*eUa%£樔"¿愣<9{6ᐽQYO㈍
mysql_backup-1 | GI&m³²£塏
s®}ZᄹX쓌Il
mysql_backup-1 | 2025/01/29 18:20:00 ERROR can't backup database err="can't open the gzip file: open dump.sql.gz: no such file or directory"
It seems the error is related to the file being displayed on the screen instead of being saved to disk?
Note: Rolling back to 1.0.1 version solves this issue
I have the same error.
2025-02-11 16:30:00 2025/02/11 09:30:00 ERROR can't backup database err="can't open the gzip file: open dump.sql.gz: no such file or directory"
I will take it.
I have encountered similar problem and here is there problem
-
The gzip output is sent to
os.stdoutrather than a file here https://github.com/appleboy/docker-backup-database/blob/a6ae8491202a3bbbe8affb267f39bc8ca2ed29c3/pkg/dbdump/mysql/mysql.go#L77 -
If above was fixed, the gzip will mostly be empty since the
mysqldumpoutput is sent toos.stdouthttps://github.com/appleboy/docker-backup-database/blob/a6ae8491202a3bbbe8affb267f39bc8ca2ed29c3/pkg/dbdump/mysql/mysql.go#L39
Unfortunately, this is also a problem with PostgreSQL, just like with the MySQL dump code.
The problem can be fixed by either:
-
Manually creating the dump file and redirecting the dump command to the file pointer.
-
Using the native dump flags, such as
-Fc -f${d.DumpName}for PostgreSQL and--compress --result-file=${d.DumpName}for MySQL.
I'm happy to contribute a fix, depending on which of the above methods is preferred.
I think https://github.com/appleboy/docker-backup-database/pull/21 would fix this
I have a working fork https://github.com/trim21/docker-backup-database/tree/master if you need it now, I'm trying to submit these changes to here.