Back

[SOLVED] Cron for backup 💾

  • 2
  • Self Hosted
wilStark43
17 Mar, 2023, 17:35

yes, exist

TL;DR
The post is about a solved issue with setting up a cron job for backup. The solution involved updating Docker and Docker-compose. The user also suggested uninstalling the old compose and installing Docker Compose v2. Another suggestion was to check the cron path and to add the -T flag to the docker compose command. The cron command was updated to include piping output to a log file. The user also mentioned a potential problem with Docker Compose for the root account and recommended checking the post-installation steps. The user later provided a modified version of the backup.sh script. The original poster confirmed they were still experiencing the issue despite the suggestions.
Binyamin
17 Mar, 2023, 17:38

OK, sorry I've made a mistake Try this

TypeScript
#!/bin/sh
cd /home/ubuntu/appwrite

mkdir -p backup

/usr/local/bin/docker-compose -f /home/ubuntu/appwrite/docker-compose.yml exec mariadb sh -c 'exec mysqldump --all-databases --add-drop-database -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' > ./backup/dump.sql

appwrite_volumes=(uploads cache config certificates functions)
for volume in ${appwrite_volumes[@]}; do
    mkdir -p backup && docker run --rm --volumes-from "$(docker-compose ps -q appwrite)" -v $PWD/backup:/backup ubuntu bash -c "cd /storage/$volume && tar cvf /backup/$volume.tar ."
done
wilStark43
17 Mar, 2023, 17:51

I continue with the problem. Thank you so much for your time and effort!

Drake
17 Mar, 2023, 18:27

did you get it working?

wilStark43
17 Mar, 2023, 18:57

Not yet 🥲

Drake
17 Mar, 2023, 19:03

weird...so btw, you shouldn't need to run sudo with docker. you may have missed a post installation step: https://docs.docker.com/engine/install/linux-postinstall/

i tested by adding a cron job for my user (rather than root). the cron job had:

TypeScript
*/5 * * * * cd [path to appwrite folder] && ./backup.sh

I used the original backup.sh script.

I wonder if you have a problem with docker compose for your root account

wilStark43
17 Mar, 2023, 19:57

everything happens normally when I run the backup.sh script directly in cmd

wilStark43
17 Mar, 2023, 19:58

Files are generated

Binyamin
17 Mar, 2023, 19:58

Yes of course. The problem is with cron path

Drake
17 Mar, 2023, 20:12

perhaps it would be good to try and get some output. try to update your crontab command to:

TypeScript
cd /home/ubuntu/appwrite && ./backup.sh > /tmp/cron-backup.log 2>&1
wilStark43
17 Mar, 2023, 20:22
TypeScript
./
./app-63ab55ce4321283aa7fe/
./app-63ab55ce4321283aa7fe/63c9aa8377f9fb2109d7/```
wilStark43
17 Mar, 2023, 20:23

I get this error: the input device is not a TTY

wilStark43
17 Mar, 2023, 20:23

the rest is basically the same as normal operation

Drake
17 Mar, 2023, 20:24

Interesting that it doesn't work for you though...

You can try adding -T flag to the docker compose command

wilStark43
17 Mar, 2023, 20:40

I no longer get the TTY error and the file is still empty

Drake
17 Mar, 2023, 20:43

How did you install docker?

Drake
17 Mar, 2023, 20:46

Can you test docker compose version in the script? You can probably comment out everything else while we troubleshoot the docker compose problem

wilStark43
17 Mar, 2023, 21:08
wilStark43
17 Mar, 2023, 21:08

like this link

Drake
17 Mar, 2023, 21:18

this is an old docker compose 👀 you need docker compose v2

Drake
17 Mar, 2023, 21:19

you should definitely try and uninstall that old compose. maybe it was installed via pip?

wilStark43
18 Mar, 2023, 16:51

@Drake @Binyamin after updating everything, docker and docker-compose the problem was solved. I really appreciate your help!

wilStark43
18 Mar, 2023, 16:52

[SOLVED] Cron for backup 💾

Suiii
21 Dec, 2023, 15:55

checking

Drake
21 Dec, 2023, 15:59

Please don't post in an old thread like this. If you need help, create a new post

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more