Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Support Installation & Updates
  1. OpenProject
  2. Forums
  3. Support Installation & Updates
  4. Backup script and cron job

Backup script and cron job

Added by Tobias Braun over 6 years ago

Hi,

I try to configure a cron job to do a daily backup by executin the openproject backup script openproject run backup

I created this entry with crontab -e

00 03 * * * /var/db/openproject/script/backupOpenProject 

This should execute the following script:

sudo openproject run backup
echo "Nightly Backup Successful: $(date)" >> /var/db/openproject/OP_backup.log

I tried the script manually but it gives me the error 

: not found exec: backup 

Do I need to specify here more? I guess this is a ruby script. 

Thanks,

Tobias


Replies (5)

RE: Backup script and cron job - Added by Oliver Günther over 6 years ago

Hi Tobias,

I would suggest you avoid running this as a root cron entry. Instead, try the following: crontab -e -u openproject

And within the script, it should suffice to simply state openproject run backup .

Best,

Oliver

RE: Backup script and cron job - Added by Tobias Braun over 6 years ago

Hi Oliver,

you mean like that?

00 03 * * * openproject run backup

KR,

Tobias

RE: Backup script and cron job - Added by Tobias Braun over 6 years ago

Works, Thanks!

RE: Backup script and cron job - Added by Rob BreakEats over 6 years ago

I have a similar request but I have a Docker installation.  I don't know of an equivalent "openproject" executable.  I logged into the container and found the packaging/scripts/backup file but it appears to depend on APP_NAME which defaulted to 'backup' when I simply ran the script.  I think I can cobble something together to create a cron job to exec into the container and pass in an environment variable APP_NAME = 'openproject' but this all appears very cumbersome.  Is there an easier way?

RE: Backup script and cron job - Added by Rob BreakEats over 6 years ago

Just to follow up with my previous challenges getting the backups to run with a docker installation...

The openproject.org guide for backups with a docker installation are here: https://www.openproject.org/operations/backup/backup-guide-docker-installation/.   Unfortunately the pgdata directory is only readable by a special user and any change to the permissions will cause errors.  I believe this is because backing up a PostgreSQL database is not as straightforward as copying the intermediate state of the files.  I investigated using 'barman' to perform periodic "physical" backups of the database but the changes to the docker image to support barman became too complex.  I instead opted to follow the same process as the openproject backup scripts and perform periodic "logical" backups of the database via pg_dump.  The database snapshot(s) will then be stored under the openproject/static directory which can then be backed up using the same process as described in the openproject.org guide.

The key is how to kick off these periodic logical backups.  I am a complete novice when it comes to Ruby on Rails and Rake but I noticed a Rake task called backup which will perform the pg_dump operation.  Although not the best practices for a docker installation, I created a very basic script to find the container ID where openproject is running and then execute the Rake task inside that container:

#!/bin/bash

containerID=`docker ps | grep openproject | awk '{print $1}'`

docker exec -e RAILS_ENV=production $containerID bundle exec rake backup:database:create[/var/db/openproject/pgdumps/openproject-production-db.backup]

(Note that this will continue to overwrite the same file each logical backup which is find for my application; you may want to add a variable to the filename, like a date string, to preserve more than one logical backup).

I then run a cron job on the main host to periodically kick off the Rake task in the container.  This Rake backup task is not as comprehensive as the backup script included in the packages directory since it only takes logical backups of the database and doesn't backup configurations, but it is a start.

I am open to hearing about a method that is better supported but hopefully this info will help someone else.

Best regards

  • (1 - 5/5)
Loading...