#!/bin/bash

set -e

# Back up the shared directory, which includes uploaded images and documents
tar cjpf <%= @shared_filename %> -C /var/www/toolkit shared
openssl dgst -md5 <%= @shared_filename %> > <%= @shared_filename + ".md5" %>

# Back up the database
pg_dump <%= @database %> -Z 1 -f <%= @dbdump_filename %>
openssl dgst -md5 <%= @dbdump_filename %> > <%= @dbdump_filename + ".md5" %>

#!/bin/bash

set -e

# Back up the shared directory, which includes uploaded images and documents
tar --exclude="*.log" -cjpf <%= @shared_filename %> -C /var/www/toolkit shared
openssl dgst -md5 <%= @shared_filename %> > <%= @shared_filename + ".md5" %>

# Back up the database
pg_dump <%= @database %> -Z 1 -f <%= @dbdump_filename %>
openssl dgst -md5 <%= @dbdump_filename %> > <%= @dbdump_filename + ".md5" %>

Exclude log files from the backup.
Exclude log files from the backup.

The backups are often failing because the log files are changing
while being read. Rather than ignoring all read errors
(--ignore-read-error) we'll exclude the logs instead.
