Difference between revisions of "Passbolt CE Backup and Restoration"
From Notes_Wiki
| (One intermediate revision by the same user not shown) | |||
| Line 105: | Line 105: | ||
| sudo chmod 640 /etc/passbolt/passbolt.php | sudo chmod 640 /etc/passbolt/passbolt.php | ||
| </pre> | </pre> | ||
| Edit /etc/passbolt/passbolt.php to ensure fullBaseUrl is correctly pointing to your server’s IP or domain. | |||
| Set'fullBaseUrl' => 'https://your-server-ip', | |||
| === 2.3 Restore GPG Keys === | === 2.3 Restore GPG Keys === | ||
| Line 144: | Line 147: | ||
| * Users can log in successfully. | * Users can log in successfully. | ||
| [[Main Page|Home]] > [[Ubuntu]] > [[Ubuntu 22.04]] > [[Ubuntu 22.04 Passbolt setup]] > [[Passbolt CE Backup and Restoration]] | [[Main Page|Home]] > [[Ubuntu]] > [[Ubuntu 22.04]] > [[Ubuntu 22.04 Passbolt setup]] > [[Passbolt CE Backup and Restoration]] | ||
Latest revision as of 08:05, 30 May 2025
Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 Passbolt setup > Passbolt CE Backup and Restoration
Passbolt CE Backup and Restoration
To back up and restore a Passbolt Community Edition (CE) instance, follow these steps:
1. Backup Script Creation
Create the backup script file:
vim passbolt_backup.sh
Add the following content:
#!/bin/bash
webserver_user=www-data
if ! command -v mysqldump &> /dev/null
then
    echo "+------------------------------------------------------------------------------------------+"
    echo "| mysqldump is required to run this script                                                |"
    echo "| Try installing either mysql-server or mariadb-server to correct this                    |"
    echo "+------------------------------------------------------------------------------------------+"
    exit
fi
backup_dir="/tmp"
backup_dir_date=$backup_dir/backup-$(date +"%Y-%m-%d--%H-%M-%S")
backup_file=$backup_dir_date.tar.gz
if [ -f /.dockerenv ]
then
    echo "+------------------------------------------------------------------------------------------+"
    echo "Docker detected"
    echo "+------------------------------------------------------------------------------------------+"
    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
    echo "Copying /etc/environment to $backup_dir_date"
    cp /etc/environment $backup_dir_date/.
else
    if [ -z ${webserver_user} ]
    then
        echo "+------------------------------------------------------------------------------------------+"
        echo "| Webserver user not set in the script                                                    |"
        echo "| Please correct this and re-run the script                                               |"
        echo "+------------------------------------------------------------------------------------------+"
        exit
    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"
    su -s /bin/bash -c "/usr/share/php/passbolt/bin/cake passbolt mysql_export --dir $backup_dir_date" $webserver_user
    echo "Copying /etc/passbolt/passbolt.php to $backup_dir_date"
    cp /etc/passbolt/passbolt.php $backup_dir_date/.
fi
echo "Copying GPG keys to $backup_dir_date"
cp /etc/passbolt/gpg/serverkey_private.asc $backup_dir_date/.
cp /etc/passbolt/gpg/serverkey.asc $backup_dir_date/.
echo "Creating archive of $backup_dir_date"
tar -czvf $backup_file -C $backup_dir_date .
echo "Cleaning up temporary files"
rm $backup_dir_date/*
rmdir $backup_dir_date
echo "Backup completed. File saved as $backup_file"
Make the script executable:
chmod +x passbolt_backup.sh
Run the script:
./passbolt_backup.sh
2. Restoration Process
2.1 Extract the Backup Archive
tar -xzvf /tmp/backup-YYYY-MM-DD--HH-MM-SS.tar.gz -C /tmp/
2.2 Restore Passbolt Configuration File
cd /tmp sudo mv /tmp/passbolt.php /etc/passbolt/passbolt.php sudo chown www-data:www-data /etc/passbolt/passbolt.php sudo chmod 640 /etc/passbolt/passbolt.php
Edit /etc/passbolt/passbolt.php to ensure fullBaseUrl is correctly pointing to your server’s IP or domain. Set'fullBaseUrl' => 'https://your-server-ip',
2.3 Restore GPG Keys
sudo cp /tmp/serverkey.asc /etc/passbolt/gpg/serverkey.asc sudo cp /tmp/serverkey_private.asc /etc/passbolt/gpg/serverkey_private.asc sudo chown www-data:www-data /etc/passbolt/gpg/serverkey.asc sudo chown www-data:www-data /etc/passbolt/gpg/serverkey_private.asc sudo chmod 440 /etc/passbolt/gpg/serverkey.asc sudo chmod 440 /etc/passbolt/gpg/serverkey_private.asc
2.4 Restore the Database
mysql -u passbolt_user -p passbolt_database < /path/to/backup.sql
Example:
mysql -u passboltadmin -p passboltdb < /tmp/backup_1740825565.sql
2.5 Verify the Restoration
Run the Passbolt health check:
sudo -H -u www-data bash -c "/usr/share/php/passbolt/bin/cake passbolt healthcheck"
Make sure:
- The login page is accessible.
- Users can log in successfully.
Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 Passbolt setup > Passbolt CE Backup and Restoration

