Crontab setup on docker compose installation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FilippoLec
    Junior Member
    • Feb 2026
    • 10

    #1

    Crontab setup on docker compose installation

    I recently got into a massive headache because I lost almost 10 months of data for (probably) a stupid mistake of mine. The closest backup I had was from 8 months ago so I decided to add a crontab job to backup all the espocrm data every day.

    I read the documentation at https://docs.espocrm.com/administrat...ing-up-crontab, but I still haven't figured some things:
    1. What is the espocrm instance folder for a docker compose instance? Is it /var/www/..., /espocrm-docker/espocrm or a thing in the docker espocrm container itself?
    2. Do I have to set the crontab on the main machine running docker or in the docker espocrm itself?
    3. Can I make crontab run the backup-docker-container.sh script?
    4. How do I check if it is working before realizing it isn't?

    I've never worked with crontab and I don't want to mess it up (again) so I am asking before doing anything.

    Thanks for any time you put into helping me <3.
    Last edited by FilippoLec; 02-26-2026, 05:35 PM.
  • heint
    Member
    • Jun 2025
    • 72

    #2
    Greetings, FilippoLec,

    To create a custom crontab that will run a backup command for you in a preset timeline, you need to download an official script to the espo-docker folder from Espo documentation and insert the corresponding line into the host crontab under the respective user with proper rights.

    Documentation link where i get the download link: https://docs.espocrm.com/administrat...r-installation

    1. wget https://raw.githubusercontent.com/es...r-container.sh to your espo-dockerdirectory.
    2. Paste a line to your crontab configuration. My line looks like this:
    HTML Code:
    30 1 * * * sudo bash /var/www/html/espo-docker/backup-docker-container.sh espocrm /var/www/html/espo-docker/backups >> /var/www/html/espo-docker/backups/espo-backup.log 2>&1
    You should change the frequency of this event and replace all paths with your relative ones. Also, the "espo-back.log" part can be omitted.
    As a result, you will get a tar.gz file with the necessary backup files every gap of time you've been setting it for.

    Regarding your questions:
    1. What is the espocrm instance folder for a docker compose instance? Is it /var/www/..., /espocrm-docker/espocrm or a thing in the docker espocrm container itself?
    -
    When you install Espo via the Docker script, you can see all the important directories inside this docker container. To see Espo folders without "docker exec" commands, you can add the "./" symbol to the espocrm volume so it will look like this: "./espocrm:/var/www/html". After that, you will see the corresponding Espo folder directly on your server at /var/www/...

    2. Do I have to set the crontab on the main machine running docker or in the docker espocrm itself?
    - On the main machine (host). Under the user that has access to edit the mentioned Docker folder.

    4. How do I check if it is working before realizing it isn't?
    - You can simply run the command from the crontab line above in your terminal:
    HTML Code:
    sudo bash /var/www/html/espo-docker/backup-docker-container.sh espocrm /var/www/html/espo-docker/backups
    Documentation example:
    HTML Code:
    sudo bash backup-docker-container.sh CONTAINER_NAME ./BACKUP_DIR
    Hope this will help.
    Last edited by heint; 02-27-2026, 03:25 PM.

    Comment

    • FilippoLec
      Junior Member
      • Feb 2026
      • 10

      #3
      Thank you very much heint for the accurate reply.

      I have my espocrm-docker directory at /root/espocrm-docker, and I keep the backups at /root/espocrm-backups, so I would assume the line in my crontab would look like this (for a backup every day at 20:00):

      HTML Code:
      0 20 * * * sudo bash /root/espocrm-docker/backup-docker-container.sh espocrm /root/espocrm-backups >> /root/espocrm-backups/espo-backup.log 2>&1
      I run the line in the terminal and it worked.

      The last thing I would like (don't need but would be nice for redundancy and/or history of data) is to have the backups placed in a folder with the backup date name (backup done 28/02/2026 at 20:04 would be placed in a folder at /root/espocrm-backups/2026-02-28-20-04/<backup_files>) is this possible in a not very complicated way?

      Regarding the first question answer: does it mean that when the guide refers to "installed EspoCRM directory" or "PATH_TO_ESPOCRM" it means the docker container directory?
      Last edited by FilippoLec; 02-28-2026, 07:57 PM.

      Comment

      Working...