I want to schedule backups of my Ubuntu EC2’s EBS on a daily rolling schedule – ie a backup will occur once each day, and after 7 days the oldest snapshot is deleted – so there will always be 1 weeks worth of backups.
Read on for the implementation.
I want to schedule backups of my Ubuntu EC2’s EBS on a daily rolling schedule – ie a backup will occur once each day, and after 7 days the oldest snapshot is deleted – so there will always be 1 weeks worth of backups.
Read on for the implementation.
When you create an Amazon EC2 instance, you’re given a .PEM private key allowing for passwordless entry to your server. Losing this key can be pretty costly but below I’ll show how to get you back in again.
We’ve lost our PEM key or the one we have isn’t working:
$ ssh -vvv -i /path/to/my.pem ubuntu@host.com
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
...
debug2: key: /path/to/my.pem (0x0), explicit
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /path/to/my.pem
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA 99:99:aa:9a:aa:99:99:a9:aa:99:99:99:99:9a:99:aa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
We need to set a new authorized_key on our server. To do this we’ll:
I don’t like big wordy tutorials so here’s a tl;dr of all steps involved:
sudo mount /dev/xvdf1 /mnt/tmp -t ext4
cp ~/.ssh/authorized_keys /mnt/tmp/home/ubuntu/.ssh/authorized_keys
sudo umount /mnt/tmp
In my personal case, the above didn’t help and I was still getting the error Permission denied (publickey). I had to also copy E2‘s sshd_config because I’d borked E‘s and it was the actual reason I couldn’t SSH in.
So before the umount line above, also do:
sudo cp /etc/ssh/sshd_config /mnt/tmp/etc/ssh/sshd_config
mkdir /mnt/tmp/home/ubuntu/.ssh/bak
mv /mnt/tmp/home/ubuntu/.ssh/id_rsa /mnt/tmp/home/ubuntu/.ssh/id_rsa.pub /mnt/tmp/home/ubuntu/.ssh/known_hosts /mnt/tmp/home/ubuntu/.ssh/bak
Hope this helps.
For those lucky Kodi users still owning an NYXBoard Hybrid, wake on USB is essential for a seamless HTPC experience. Below I’ll explain each step in getting that happening as well as some skin customisations to make things a little nicer down the road.
Wake on USB comes in 2 stages:
For this tutorial I’m running an Intel NUC 54250WYK with OpenELEC.
JQuery UI supports a really handy feature called content via AJAX whereby when you click/display a tab, it will create a div element to load your content into, then perform the AJAX call and drop it in. But what happens when you want to specify the element to load the AJAX request into? Thankfully after a bit of digging around it’s not only possible, but pretty easy.
Here’s an example of AJAX load with JQuery UI Tabs:
<div id="tabs">
<ul>
<li><a href="ajax-content-1.html">Tab 1</a></li>
<li><a href="ajax-content-2.html">Tab 2</a></li>
<li><a href="ajax-content-3.html">Tab 3</a></li>
</ul>
</div>
And here’s how you can specify the panel elements. Simply add an aria-controls attribute to your tab LI element that points to the ID of your target panel element:
<div id="tabs">
<ul>
<li aria-controls="my-first-tab"><a href="ajax-content-1.html">Tab 1</a></li>
<li aria-controls="my-second-tab"><a href="ajax-content-2.html">Tab 2</a></li>
<li aria-controls="my-third-tab"><a href="ajax-content-3.html">Tab 3</a></li>
</ul>
<div id="my-first-tab"></div>
<div id="my-second-tab"></div>
<div id="my-third-tab"></div>
</div>
If you refresh or come back to a site often, it’s handy to have JQuery UI tabs remember which tab you were last on as you left. This simple script will handle that for you:
jQuery(function($) {
var index = 'qpsstats-active-tab';
// Define friendly data store name
var dataStore = window.sessionStorage;
var oldIndex = 0;
// Start magic!
try {
// getter: Fetch previous value
oldIndex = dataStore.getItem(index);
} catch(e) {}
$( "#tabs" ).tabs({
active: oldIndex,
activate: function(event, ui) {
// Get future value
var newIndex = ui.newTab.parent().children().index(ui.newTab);
// Set future value
try {
dataStore.setItem( index, newIndex );
} catch(e) {}
}
});
});
No other code is necessary. Add your tab markup as you normally would (Remember to give it a matching ID):
<div id="tabs">
<ul>
<li><a href="#tabs-1">Tab 1</a></li>
<li><a href="#tabs-2">Tab 2</a></li>
<li><a href="#tabs-3">Tab 3</a></li>
</ul>
<div id="tabs-1">
first tab
</div>
<div id="tabs-2">
second tab
</div>
<div id="tabs-3">
third tab
</div>
</div>
If you have a bunch of MP4 files and want to convert to MKV without needing to reencode each file, this can be done with a super handy little tool called avconv.
You’ll need homebrew for this step.
brew install avtools
I have a folder of MP4 files. To bulk convert them:
for f in *.mp4; do avconv -i "$f" -codec copy -map 0 "${f%.mp4}.mkv"; done
The above will create identically named MKVs next to your MP4s. Once you’re happy, just delete all your MP4s.
If you have identically named ASS subtitle files next to your shiny new MKVs, you can bulk merge them using mkvmerge from mkvtoolnix with:
brew install mkvtoolnix
for f in *.mkv; do mkvmerge -o "./muxed/$f" "$f" "${f%.mkv}.ass"; done
Thanks to user MestreLion for his answer on AskUbuntu.
Welcome back to my simple to-do application tutorial for Laravel 5. This tutorial is relatively long so I’ve broken it up into multiple posts.
The source for each part can also be found on GitHub.
So far we’ve learned how to install and set up Laravel, set up some project and task nested resources and display them to the user. Create, edit and delete functionality has also been implemented. In this chapter we’ll finish things off by adding form validation.
Welcome back to my simple to-do application tutorial for Laravel 5. This tutorial is relatively long so I’ve broken it up into multiple posts.
The source for each part can also be found on GitHub.
So far we’ve learned how to install and set up Laravel, set up some project and task resources and displayed them to the user. In this chapter we’ll learn how to set up create, edit and delete pages/actions.
Welcome back to my simple to-do application tutorial for Laravel 5. This tutorial is relatively long so I’ve broken it up into multiple posts.
The source for each part can also be found on GitHub.
So far we have a working database complete with seed data and a bunch of routes for displaying, editing and deleting our projects and tasks. In this second chapter I’ll cover controllers, models (with relationships), views (including the blade templating language and layouts) and route model binding.
With the release of Laravel 5, there have been a bunch of backwards incompatible changes, new features added as well as the usual influx of new users so I thought I’d take the time to redo my basic to-do application with Laravel 5. The app covers a wide range of concepts, links to relevant learning material where possible and should make for a great introduction to the framework.
This tutorial is relatively long so I’ve broken it up into multiple posts.
The source for each part can also be found on GitHub.
Today will cover installation, configuration, artisan, migration, seeding and routes.