Backup Laravel to AWS S3 Using SnapShooter
SnapShooter provides an easier way to backup your Laravel database and website directory, compress them and transfer it automatically from your Laravel server to AWS S3.
Add a Server to Snapshooter
First, you will need to add the Laravel server to the Snapshooter. Follow the below steps to add a server to Snapshooter:
Step 1 - First, go to the SnapShooter website and register for their 14-day free trial.
Step 2 - On the SnapShooter dashboard, click on the Servers in the left sidebar. You should see the following screen:
Step 3 - Click on the Connect Server. You should see the following screen:
Step 4 - Copy and paste the code shown in the above image to your server:
curl -sSL "https://ingestor.snapshooter.com/api/server/add?token=eyJpdiI6IlFrOFE2d3ZrT2NaRHhSUmZWdDFUY3c9PSIsInZhbHVlIjoiQzQrK1hpazhMeFgzL0s3ZGdKeFZtUT09IiwibWFjIjoiNGE4MGEwYjhhNjM1OGNiNDU5N2Y1NDkxYjhlMjNlYjcwNjcyZjNlZDIzNDNkNDhhNGFmOGNkYmQ0ODU2MTY1NSIsInRhZyI6IiJ9&key=5895" | bash
Once your server is connected to the Snapshooter, you will get the following output:
Welcome to SnapShooter Server SetupEnvironment Detected: OS: linux, OS Type: amd64Installing SSH public keyCreating temp SSH key filegrep: /root/.ssh/authorized_keys: No such file or directorycp: cannot stat '/root/.ssh/authorized_keys': No such file or directoryCreating authorized_keys backup /root/.ssh/authorized_keys.bak-1653474994Key Installed /root/.ssh/authorized_keysRemoving temp SSH key fileScanning SSH configChecking 22matched (22)SSH test confirmed, Server Added to SnapShooter ...
Step 5 - Go back to your web browser, you should see your added server on the following screen:
Attache AWS S3 to Snapshooter
Next, you will need to attack the external backup storage like AWS S3 to the SnapShooter.
Click here to attach the AWS S3 to SnapShooter. You should see the following screen:
Choose a Friendly Name, Select AWS S3, select region, type your access key and secret access key, type the correct bucket name, and press the Attach External Storage button.
Create a Backup Job to Schedule Laravel Backup to AWS S3
Next, you will need to create a backup job to automate Laravel backup to AWS S3. Follow the below steps to automate Laravel backup:
Step 1 - On the SnapShooter dashboard, click on the Backup Jobs in the left pane, you should see the following screen:
Step 2 - Click on the Create New Job. You should see the following screen:
Step 3 - Click on the Laravel. You should see the following screen:
Step 4 - Provide your backup job name and click on the Continue button. You should see the following screen:
Step 5 - Select your server from where you want to backup Laravel, then click on the Next button. You should see the Laravel configuration screen:
Step 6 - Provide your Laravel root directory path and click on the Test button. You should see the following screen:
Step 7 - Click on the Save and Next button. You will be asked to select the external storage:
Step 8 - Select aws laravel as a storage and click on the Set Storage button. You should see the backup schedule screen:
Step 9 - Define your backup schedule, and retention policy and click on the Set Schedule and Finish button. You should see the following screen:
Step 10 - Now, click on the Backup Now button to run your first backup. Once the backup job is executed successfully, you should see the following screen:
You can also verify your backup by accessing the AWS S3. You should see your Laravel site backup on the following screen:
Thank you for helping us improve!