How to play/download movies from youtube/vimeo.
Description
I wrote a tiny bash script which allows user to play (via mplayer) online videosand to download them (via wget): video-dl.sh.
The arguments are:
video-dl.sh site video_id [handler [options]]
where:
siteisytfor youtube.com orvmfor vimeo.com.video_idis a part of URL, for example:
j1kDe4F868kfor http://www.youtube.com/watch?v=j1kDe4F868k
6999927for http://vimeo.com/6999927handleris a program accepting video stream from standard input. The default handler is mplayer.
How to play a movie:
video-dl.sh yt j1kDe4F868k
How to download a movie:
video-dl.sh yt j1kDe4F868k wget -O /tmp/video.mp4
History of changes
- 26 Jul 2010
Fixed broken youtube support (added theasvURL parameter).
Youtube videos are now automatically downloaded in best quality. - 7 Sep 2009
First public release.
How to backup a running GNU/Linux server.
Objective
It's required to perform a scheduled backup of a running server. All backup data should be stored as is (not in tar archives or special dump formats). It should be enough just to replace a broken hard drive with a backup and restart the server.
Solution
Apparently we need a backup hard drive(s) with equal or higher capacity than the operating one(s).
In order to make a backup of a running system, we need a filesystem that supports snapshotting. XFS is one of them. It's used in this solution. XFS is supported by Linux kernel natively, so we don't need any additional drivers.
There are two tools which allow us to make a dump and restore an XFS filesystem: xfsdump and xfsrestore. Besides that, we also need mkfs.xfs to create an XFS partition. All these tools can be installed in Gentoo using the following command:
emerege -av xfsdump xfsprogs
I wrote a bash script wrapping these tools and performing a full system backup: xfs-backup.sh.
The script backs up a list of filesystems. All configuration parameters are specified inside the script. The mandatory parameters are:
BACKUP_SRCis a list of mount points of the filesystems to be backuped.BACKUP_DSTis a list of corresponding partitions storing the backup data. Each of the destination partitions should be large enough to fit the source data.BACKUP_MNTis a common mount point for all destination partitions. A partition is mounted here while the backup of a corresponding source is being run.INV_DIRis a directory storing the XFS inventory. It may vary depending on the destribution.
Specify the -b option to backup the sources. The script performs a full backup on the first run and applies up to 9 levels of incremental backups afterwards. When the 9th level is reached, the scripts resets the inventory and runs a full backup again. Reset of the inventory backup may be forced by passing the -f parameter.
If you want to have your backup drive removed (physically or just from the
kernel's recognition) while it's not being used, then specify the backup device
information (DEV_HOST, DEV_BUS, DEV_TARGET, DEV_LUN_ID).
When you need to restore information and the backup device is disabled, use the -e option to enable the device and -d to disable it back.
You may use cron to schedule the script to run automatically at a certain time. See the Gentoo Linux Cron Guide for details.
History of changes
- 20 Jul 2009
Added options to enable/disable the backup device. - 12 Apr 2009
The script does not allow to execute backup for non-root users anymore.
The script now can add/remove a backup drive using thesysinterface. - 17 Jan 2009
First public release.
How to backup a notebook.
I wrote a tiny bash script backuping my Thinkpad X200 content to my home server via ftp: x200-backup.sh.
The configuration variables are:
SERVER- IP address or domain name of the server;USER- user name to log in with;SOURCE_DIRS- a list of local directories to be backed up;BACKUP_DIR- a remote directory to store the backup in.