Backing up YII installation ( Solved )

I am getting started with YII and working through all the potential issues that may come up before really starting on my project.

On of the few issues left is that of performing backups.

I see that there are several backup add-ons, however, I prefer to set up a cron job to just take care of it.

As far as I can tell, with the exception of composer, YII and the application are fully contained within the application directory ( i.e. /home/nginx/domains/my.yiiapp.com/public/ ), and the database.

Are there any cases were yii or any of its plugins would store any state information anywhere else?

I know there is config info stored in the nginx config files and such, but that is not a problem.

I plan on writing a script that will:

  1. extract the database, drop it into a directory in the app,

  2. zip up the app directory

  3. copy it to off site storage

Does anyone know of anything else I need to do?

Thanks

-John

this is all. sometimes you should adjust permisions

if you create a backup without permisions.

OK, so I have created a backup script called backup.sh ( original right… ;D ) that lives in the ‘public’ directory above “basic”.

It makes a backup of the sql database and stores it in ‘basic’

It then cleans out the ‘basic/runtime’ and ‘basic/web/assets’ directories. ( no need to back these up, they will be recreated as needed next time the app is accessed )

It then creates a compressed tar file of ‘basic’ ( including the SQL backup ) in the ‘backup’ directory at the same level as the ‘public’ directory.

In my case I then copy the TAR file to Amazon S3.

Note that this does not handle any file permissions. So if you need to restore from this backup, you will need to mess with the file permissions to get up and running again.

Here is my backup.sh script.




mysqldump --user=myuser --password=myuserpass MyDatabasename > basic/MyDatabasename.sql

rm -rf basic/runtime/*

rm -rf basic/web/assets/*

tar cJvf ../backup/yii.tar.xz basic

mv -f basic/Mydataqbasename.sql ../backup

# aws s3 cp ../backup/yii.tar.xz s3://mys3bucketname/yii

# aws s3 ls   s3://mys3bucketname/yii



I don’t think it matters but I am running CentOS / Centmin Mod with Nginx/php-fpm on AWS using the free tier.

Yii screams!!! With production mode on, I get 90 requests/sec doing some complex DB queries. Of course most of them are really cache hits, but it beats the crap out of what I was getting on Apache…

-John