Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup cronjob fail due to tar file reporting file changes during backup #134

Open
bernardmaltais opened this issue Jun 2, 2022 · 0 comments

Comments

@bernardmaltais
Copy link
Contributor

bernardmaltais commented Jun 2, 2022

I ran into a similar issue as what @Stemirabo reported during restore and fixed via a patch.

I have fixed my issue with a patch for the cronjob script... but ultimately, I think the whole script should be made customizable via the values files. This will require quite a bit of work and would be a breaking change... so, I did not bother creating a pull request for it.

I think discussing long term possibilities for making script more customizable is required to better plan how it should be implemented.

Here is a copy of the patch I created to fix the problem:

spec:
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: drush
              command:
                - /bin/sh
                - '-c'
                - |
                  # Errors should fail the job
                  set -e
                  set +x

                  # Wait for DB to be available
                  until drush sql:query 'SHOW GLOBAL STATUS LIKE "Uptime";'; do echo Waiting for DB; sleep 3; done;
                  echo DB available;

                  # Check Drush status
                  drush status

                  # Run cron
                  BACKUPNAME=$(date +%Y%m%d.%H%M%S)
                  mkdir -p /backup/$BACKUPNAME
                  echo "Backup folder name: $BACKUPNAME"

                  echo "Backup DB"
                  drush -y sql-dump --skip-tables-list=cache,cache_* | gzip > /backup/$BACKUPNAME/db.sql.gz
                  echo "...backup DB completed."

                  echo "Backup public files"
                  set +e
                  tar --exclude="./js" --exclude="./css" --exclude="./styles" -czf /backup/$BACKUPNAME/files.tar.gz --directory=sites/default/files .
                  echo "...backup public files completed."
                  exitcode=$?
                  if [ "$exitcode" != "1" ] && [ "$exitcode" != "0" ];
                  then
                    exit $exitcode
                  fi
                  set -e

                  echo "Backup private files"
                  tar --exclude="./config" -czf /backup/$BACKUPNAME/private.tar.gz --directory=/private .

                  echo "...backup private files completed."

I guess we could run into the same issue with the private files backup... so, I might have to add the fix there to also...

I also added a bunch of echo to better see when things are completed and changed how I detect when the DB is ready. Therefore full script customization would be good as each teams using the chart might need slightly different backup and restore scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant