Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
This repository is meant to hold various scripts that passbolt users might find useful.

## backup.sh
This script takes a database dump, copies the server GPG keys, and then `tar`s them in a designated location so that it is easier to implement a good backup plan. This backup script requires the ability to run mysqldump on the host you are running it on. This means that for Docker installs you'll need to install mariadb-server. Additionally the user you run this as will need the correct permissions to access the `/etc/passbolt` directory and wherever you select as the backup directory(currently set to `/tmp`).
This script takes a database dump, copies the server GPG keys, and then `tar`s them in a designated location so that it is easier to implement a good backup plan. This backup script requires the ability to run mysqldump or mariadb-dump if you are running MariaDB > 10.4.6, on the host you are running it on. This means that for Docker installs you'll need to install mariadb-server. Additionally the user you run this as will need the correct permissions to access the `/etc/passbolt` directory and wherever you select as the backup directory(currently set to `/tmp`).
11 changes: 6 additions & 5 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ then
echo "| mysqldump is required to run this script |"
echo "| Try installing either mysql-server or mariadb-server to correct this |"
echo "+------------------------------------------------------------------------------------------+"
exit
exit 1
fi
# Set this to the location you'd like backups placed, be sure to leave off the trailing /
backup_dir="/tmp"
# If you want to change how the date is displayed edit this line
backup_dir_date=$backup_dir/backup-$(date +"%Y-%m-%d--%H-%M-%S")
backup_file=$backup_dir/backup-$(date +"%Y-%m-%d--%H-%M-%S").tar.gz
export backup_file=$backup_dir/backup-$(date +"%Y-%m-%d--%H-%M-%S").tar.gz


if [ -f /.dockerenv ]
Expand All @@ -26,7 +26,7 @@ then
su -s /bin/bash -c "mkdir $backup_dir_date" www-data
echo "Taking database backup and storing in $backup_dir_date"

su -s /bin/bash -c "./bin/cake passbolt mysql_export --dir $backup_dir_date" www-data
su -s /bin/bash -c "./bin/cake passbolt sql_export --dir $backup_dir_date" www-data
echo "+------------------------------------------------------------------------------------------+"
echo "Copying /etc/environment to $backup_dir_date"
echo "+------------------------------------------------------------------------------------------+"
Expand All @@ -38,15 +38,15 @@ else
echo "| You don't have the webserver_user set in the backup.sh file |"
echo "| Please correct this and then re-run this script |"
echo "+------------------------------------------------------------------------------------------+"
exit
exit 1
fi
echo "+------------------------------------------------------------------------------------------+"
echo "Docker not detected"
echo "+------------------------------------------------------------------------------------------+"
su -s /bin/bash -c "mkdir $backup_dir_date" $webserver_user
echo "Taking database backup and storing in $backup_dir_date"
echo "+------------------------------------------------------------------------------------------+"
su -s /bin/bash -c "/usr/share/php/passbolt/bin/cake passbolt mysql_export --dir $backup_dir_date" $webserver_user
su -s /bin/bash -c "/usr/share/php/passbolt/bin/cake passbolt sql_export --dir $backup_dir_date" $webserver_user
echo "+------------------------------------------------------------------------------------------+"
echo "Copying /etc/passbolt/passbolt.php to $backup_dir_date"
echo "+------------------------------------------------------------------------------------------+"
Expand All @@ -61,6 +61,7 @@ cp /etc/passbolt/gpg/serverkey.asc $backup_dir_date/.
echo "Creating archive of $backup_dir_date"
echo "+------------------------------------------------------------------------------------------+"
tar -czvf $backup_dir_date.tar.gz -C $backup_dir_date .
chmod 0600 $backup_dir_date.tar.gz
echo "+------------------------------------------------------------------------------------------+"
echo "Cleaning up $backup_dir"
echo "+------------------------------------------------------------------------------------------+"
Expand Down