در حال بارگذاری ...

Starting Forge Backups0:01

Before Forge offered database backups, I was paying for a service purely for the ability to back up my databases, up to an S3 compatible service. So with love and respect to the guy that created that service, I was very excited when Forge pushed out that ability natively. So let's take a look at how to set it up. So we want to go to the server we're doing the backup on and we want to go to the storage tab and the backup section. And here you can create a new backup configuration.

Configuring Backup Schedule0:20

and we want to go to the storage tab and the backup section. And here you can create a new backup configuration. So we'll fill out the details. We'll say daily backup 'cause why not? Uh, we'll say daily at maybe 2:30 AM we'll pick the tutorial database. We'll have it keep five days of backups. And if you want, we'll skip it for now. You can say, email me if anything goes wrong. And then we go onto our second screen where we're able

Setting S3 Credentials0:45

You can say, email me if anything goes wrong. And then we go onto our second screen where we're able to actually put in the credentials for where to back it up. And this is either gonna be S3 or an S3 compatible bucket somewhere. So I don't like dealing with S3. So let's go over to Digital Ocean really quickly and configure their spaces Object storage for this. So we will go to our digital Ocean account and we'll go to spaces object storage

Creating Spaces Bucket1:03

So we will go to our digital Ocean account and we'll go to spaces object storage and we'll create a new bucket. So we'll choose Atlanta 'cause that's where I live. We don't need it to be A CDN 'cause this is not being distributed to the public. And then we need to create a unique bucket name. It's globally Unique so we can say Matt Laracasts Forge. So it's actually Matt Laer, cast Forge, ATL one. It's the only one on ATL one.

So it's actually Matt Laer, cast Forge, ATL one. It's the only one on ATL one. I can put it in my default project and because it's one of my 100 free buckets I get, I'm good to go. So say Create a Spaces bucket. Alright. And now we go to settings and we grab an access key. So you can say Create Access Key. And we only wanna give it access just to this particular budget bucket.

And we only wanna give it access just to this particular budget bucket. And we need to give it read, write, delete, access. 'cause it needs to be able to upload things there. And you can name it, you can say, you know, forge backup key, create your access key. And now we have a key ID and a secret. And you gotta copy these down because after this you're never gonna see it again. Let's grab the key and let's grab the secret.

Connecting Forge to Spaces2:06

after this you're never gonna see it again. Let's grab the key and let's grab the secret. All right. And now we can go over to our new backup. We can say Provider is Digital Ocean Spaces. Region is Atlanta. Bucket is, I already don't remember when I named it. Uh, Matt Laer Casts Forge. You can put it under subdirectory so you can have more than one under this bucket. So we'll just say tutorial.

so you can have more than one under this bucket. So we'll just say tutorial. We grab our access key, we grab our secret key, and then we say Create backup configuration. And while it's creating, it's actually gonna check with Digital Ocean to make sure these are real I real credentials that it can work with and it can. So now we have a fully fully functioning daily backup that's gonna run daily at two 30, backing up the tutorial table up to

that's gonna run daily at two 30, backing up the tutorial table up to that space that we just created. And basically what it's doing for us is it's setting up a bash script to run this. And then Aron job that triggers that bash script at two 30 every morning. Now that we have this backup configuration, we can actually take actions on it, including edit the configuration,

Running and Restoring Backups3:18

we can actually take actions on it, including edit the configuration, change the provider information, copy its id, which is not that helpful for me. But also we can run a backup right now. So let's do that. And once a backup has run, we're gonna get a sec, a second section here called Recent backups. So for that backup that ran, we can say it's the daily backup, it ran just now, it was successful.

we can say it's the daily backup, it ran just now, it was successful. And we also get some options here. We can view whatever the output was from that script. We can download the backup or we can actually restore our database directly from there. And when we download that backup, we're just gonna get a compressed SQL file here. So you can open this up and you can import it directly into Table Plus or whatever else you need to share it.

So you can open this up and you can import it directly into Table Plus or whatever else you need to share it. Again, you can also just hit Restore directly and it's gonna restore it directly into that exact same database table that it came from. Or you can even go over to your storage service and you can open up your tutorial directory. That's gonna be the date and time, and then that's exact same file. You have access to it there.

and then that's exact same file. You have access to it there.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟