Moving your Frappe Site
Here’s a step-by-step guide to updating your GitHub repository with changes from your custom app, backing up your site, and moving it to another Frappe installation:
Step 1: Update GitHub with Custom App Changes
Navigate to Your Custom App Directory:
cd ~/frappe-bench/apps/your_custom_app
Check the Status of Your Repository:
git status
This shows you which files have been modified, added, or deleted.
Stage Changes: Add all modified and new files to the staging area:
git add .
Commit Changes: Write a meaningful commit message:
git commit -m "Describe the changes you made"
Push Changes to GitHub: Push the changes to your GitHub repository. You will have to use your GitHub username and key. Passwords are no longer used with GitHub:
git push origin branch_name
Replace branch_name with the branch you’re working on (e.g., main or develop).
Step 2: Backup Your Frappe Site
Backup Site Data: Run the following command to create a backup of your site:
bench --site your_site_name backup
The backup files (database and private/public files) will be saved in the ~/frappe-bench/sites/your_site_name/private/backups directory.
Copy Backup Files: Save these files to a secure location:
cp -r ~/frappe-bench/sites/your_site_name/private/backups /path/to/secure/location
Backup Custom App: If your app isn’t already in a GitHub repository, back it up manually:
tar -czvf your_custom_app.tar.gz ~/frappe-bench/apps/your_custom_app
Store this file securely as well.
Step 3: Move the Site to Another Frappe Installation
Prepare the New Frappe Installation: Ensure the new installation is running the same version of Frappe and Python as your current one. You can verify this using:
bench version
On the new server, install Frappe and ERPNext if needed:
bench init frappe-bench --frappe-branch version-15
bench get-app erpnext --branch version-15
Copy the Backup Files: Transfer the site backup files and custom app to the new server:
scp -r /path/to/backup/files user@new_server:/path/to/frappe-bench/sites/your_site_name/private/backups
scp your_custom_app.tar.gz user@new_server:/path/to/frappe-bench/apps
Extract the app on the new server:
tar -xzvf your_custom_app.tar.gz -C /path/to/frappe-bench/apps/
Install the Custom App: On the new server, install your custom app into the Frappe bench:
bench --site your_site_name install-app your_custom_app
Restore the Site Backup: Restore the backup onto the new site:
bench --site your_site_name restore /path/to/backup/database.sql.gz
Sync the Database: After restoring, ensure the database schema is synced:
bench --site your_site_name migrate
Copy Public and Private Files: Transfer and replace the public and private files for the site:
scp -r /path/to/backup/public/files user@new_server:/path/to/frappe-bench/sites/your_site_name/public/
scp -r /path/to/backup/private/files user@new_server:/path/to/frappe-bench/sites/your_site_name/private/
Restart Bench: Restart the bench to apply changes:
bench restart
Step 4: Verify the Setup
Open the site in your browser to verify everything works as expected.
Check for missing dependencies or errors:
bench --site your_site_name doctor
If issues arise, check the logs for details:
tail -f logs/your_site_name.log
By following these steps, you can ensure a seamless update, backup, and migration process while keeping your Frappe installation secure and functional. Let me know if you need assistance with any specific step!