Make samba create files with usable group permissions

I am using Samba as my file server at home and connecting to it from two different users on their own macbook laptops. The Debian server has a share directory in /var/share that either myself or any other user on the system can connect to and create files or directories in. We all want to be able to edit each others files in addition to adding or removing directories and files as well, regardless of who created or owns them.

First, I created a directory in /var/share that is owned by one user, with group of “users”. All users with access to this share are members of the ‘users’ group on the file server.

Dumping a mysql or mongo database for offsite backups

If you’re doing offsite backups of your file system, AS YOU SHOULD BE, you should also dump your database periodically and include those in your offsite backups.

Here is a simple bash script that will create a timestamped sql/gzip file of all your databases using mysqldump. You can use this file to import back into a database should you need to restore later.

First you need to install the mysql client libraries (debian):

…this should provide the mysqldump binary we will be using in the script below:

Testing a node.js express app with Mocha and Should.js

I’ve been doing more Test Driven Development the past few months with my node.js application code base.

With my latest project Wishd.me, I decided to get started early with writing tests. While skeptical at first, I have to admit it does save quite a bit of effort in debugging and peace of mind when it comes to the stability of the code.

There are a few options with Node.js, but I decided to use the Mocha framework and Should.js for testing my models and libraries.

Backing up and restoring a mongodb to a different database

I’m using mongodb as my NoSQL database of choice for Wishd.me. I needed a quick way to backup the mongo database to another server, and then load that production database in a test environment locally so I could do some testing.

Here is how I backed up mongodb using mongodump as described here

:

First, ssh to the production database server, then use mongodump with the –db argument to specify which database to dump:

This will create a ./dump folder that you can then tar up and gzip and transfer down to your local development server.

Restart a Node.js app when the server reboots

I had some issues when I first setup my Debian VPS for my node.js app over at Wishd.me when the ISP rebooted my server a couple of times unexpectedly and my node app didn’t come back online.

I didn’t find many options out there, so I wrote a node-startup script (available on github) that can be used in /etc/init.d and will restart your node.js app when the server reboots.

First, clone the repo from github: https://github.com/chovy/node-startup

Edit the node-app script with your settings for node path, node environment (ie: production or development), path to application directory (where your app.js is – this is also NODE_APP variable), and a path to a pid file.