temp dir cleaner
I’ve just released one of the my scripts I use on my computers (laptops and servers).
I developed the first version of this simple script some years ago.. it was useful to keep clean a shared temporary directory of an internal server we used for file transfers.
Then, for some reasons, I simply lost it. Some months ago I decided to rewrite it, to automatically delete old temporary files on my laptop, since I started using “sleep” over “shut down”..
Now it’s hosted on github!
simple mongo db backup script
Yesterday I was developing a new feature on Mashape and I wanted to backup my local DB.
So I wrote a small script to backup data of a list of sb (variable $DB) in a folder db-20110115 and to have it replicated on another pc in my LAN (just in case..) via ssh (with rsa key to be scheduled in cron).
#!/bin/bash
# CONFIGURATION
DBS=”db1 db2”
DUMP_LOCATION=~/backup
DIR_NAME=db-`date +%Y%m%d`
DIR_NAME_ABS=$DUMP_LOCATION/$DIR_NAME
COPY_SSH_DEST=server1:$DIR_NAME_ABS
##—
echo “Starting backup `date`”
for DB in $DBS
do
echo “Backup: $DB”
mongodump —db $DB —out $DIR_NAME_ABS
done
scp -r $DIR_NAME_ABS $COPY_SSH_DEST
echo “Backup Finished `date`”
If anyone is interested I plan to add compression and auto delete of data after two months