# SelBackup Selbackup allows user to upload easily some files on an Amazon S3 server. It also integrates a "Rotation backup system", which is very useful to get a backup of a file during a selected period (without it overcharges the server) ## Installation Installation ``` gem install selbackup ``` your_file.rb ``` require 'selbackup' ``` ## Usage ``` selbackup = SelBackup.new('key', 'secret', 'bucket', 'region') selbackup.upload_file(VotreFichier, nb_day, nb_week, nb_month) ``` Key, secret et bucket are your Amazon S3 logins. nb_day, nb_week and nb_month allow user to choose the number of daily, weekly and monthly files to keep on the server. These parameters are optionnal and are set, by default, to 7, 4 and 3. ## Backup Rotation System You can upload a lot of different files. Recommended naming convention is: `YYYY-MM-DD-filename.extension`, but you can upload files named differently. For example, you can upload a file without date (today's date will be set by default), or a file without extension. However, note that trying to upload a file whose name contains only a date (like '2013-01-01' or '2013-01-01.tgz') will return an error and the upload won't happened. Selbackup should be used every day to maximize performance. It keeps 'nb_day' daily versions, 'nb_week' weekly_version and 'nb_month' monthly version of a same file. Thus, the files rotation will proceed like this: - Each day, a file is upload - Each day, the latest daily version is removed if there are more than 'nb_days' daily file versions - Each week, the latest daily version upgrades to weekly version. - Each week, the latest weekly version is removed if there are more than 'nb_week' weekly file versions - Each month, the latest weekly version upgrades to monthly version - Each month, the latest monthly version is removed if there are more than 'nb_month' monthly file versions With default parameters, for a "file1.tgz" file, the tree server will looks like the following scheme ``` bucket/ file1.tgz/ 2013-01-01-monthly-file1.tgz # 3 last monthly versions 2013-02-01-monthly-file1.tgz 2013-03-01-monthly-file1.tgz 2013-03-08-weekly-file1.tgz # 4 last weekly versions 2013-03-15-weekly-file1.tgz 2013-03-22-weekly-file1.tgz 2013-03-29-weekly-file1.tgz 2013-04-05-daily-file1.tgz # 7 last daily versions 2013-04-06-daily-file1.tgz 2013-04-07-daily-file1.tgz 2013-04-08-daily-file1.tgz 2013-04-09-daily-file1.tgz file2.tgz/ [...] [...] ``` ## Tasks exec `rake` to run rspec tests. exec `rake test_upload['yourKey', 'yourSecret', 'yourBucket']` to run an upload test. This will create and upload files to your amazon S3 server. ## Doc You can generate documentation by executing: `sdoc` Don't forget to install the sdoc gem (`gem install sdoc`) ## Author Simon Ninon for Selectra SARL aka [Cylix](https://github.com/Cylix) ## License We are using [WTF License](LICENSE) ## Contribute 1. Fork 2. Create your branch (`git checkout -b my-branch`) 3. Commit your new features (`git commit -am 'New features'`) 4. Push (`git push origin my-branch`) 5. Make a `Pull request`