3 Comments

The Beauty of rsync and Backup Script

rsync is a command-line tool used to copy/clone files (“fast incremental file transfer“). It is a great, simple backup tool. The basic rsync command is this:

rsync -a src dest_dir

Where src is the original directory or file and dest_dir is the destination directory. Because rsync does incremental backups it only adds the file to the dest if it has been updated from the original backup.

rsync -axS src dest_dir

This is the command I use. This command can be used to backup just about anything! The options:

  • -a means archive mode which basically means to preserve the file “as is” (same permissions…)
  • -x means not to cross file systems boundaries
  • -S means to handle sparse files efficiently
  • -v option (verbose) can be used to print what rsync is doing

An important note about rsync: when src is a directory a trailing slash (/) tells rsync to copy the “contents” of the directory:

rsync -axS src_dir/ dest_dir
ls -1 dest_dir/
 file1
 file2

Without a trailing slash:

rsync -axS src_dir dest_dir
ls -1 dest_dir
 src_dir

rsync can also use file-lists containing paths of directories and files, to both include and exclude them for backup:

sudo rsync -axS --files-from="incl_file.txt" --exclude-from="excl_file.txt" src_dir dst_dir

src_dir will have to be specified and will have to be relative to paths in the file list:

cat incl_file.txt
Desktop/
rsync -axS --files-from="incl_file.txt" --exclude-from="excl_file.txt" /home/user/ dst_dir

rsync can also remove files from the dest_dir with the --delete option, so files that get added to the exclude file or taken out of the include file will removed from dest_dir.

rsync -axS --delete-excluded --files-from="incl_file.txt" --exclude-from="excl_file.txt" /home/user/ dst_dir

Backup Script

I use rsync to backup my system configurations and /home/ to make reinstalling easy. I created the script to remember the command to use, but to also easily add to the include and exclude files:

bcksysc i /etc/hostname 
 Added "/etc/hostname" to bcksysc-inc.txt include file.

Syntax:

bcksysc 
 bcksysc  - backup configurations
 i - add to the include list a file or folder
 e - add to the exclude list a file or folder
 c - create backup

Here’s the script all that needs to be done is to change the Parent Destination Directory (for backing up /home/ I copied the script to bckhome, changed the type to home and added /home/ to the include file):

So my destination directory looks like this:

ls -1 /run/media/todd/Backup/rsync/
 ...
 aspire_2012-08-31_sysc
 aspire_2012-08-31_home
3 Comments

Screencasting Done Easy (Desktop Recording)

I got to test out a good number of screencasting applications and I found a good one, and as usual the easiest was the best. I started with recordMyDesktop.

recordMyDesktop

recordMyDesktop is a basic program that works good. The GTK version has a simple UI that sets a border around the area to be recorded. I has sound recording too.

A minor thing but of note is that the window detection area is off when selecting a windows, but the reason I didn’t use recordMyDesktop was because I found the quality wasn’t that good. It could be because it uses .ogv format, or perhaps it had something to do with my system.

This is and example I did with recordMyDesktop and though it’s enlarged (OpenShot doesn’t have the ability to use the original size) the quality I wanted to be better.

Others

I tried Istanbul and a couple others all with about the same recording results. Istanbul hasn’t been developed in several years and though I got excited about xvidcap it hasn’t been developed in years either. xvidcap grabs screenshots and then concatenates them into a video. I got excited because xvidcap’s preview uses Imagemagick’s animate tool to preview the video and it was real nice. Unfortunately very little works in xvidcap anymore but taking the screenshots. To put them together I used:

fmpeg -i out%04d.xwd -r 15 -vcodec huffyuv test.avi

unfortunately the quality was no better than that of the others.

FFmpeg

The great command line tool to encode and decode video ffmpeg can also do screencasts and I read a lot of how people liked it (and I do too). To use it it’s real basic:

ffmpeg -f x11grab -s wxga -i :0.0 -sameq screencast.mpg

The quality isn’t quite what I want it to be, but I’ve seen other people have nice looking screencasts so I think it must be either my video card or my video driver.

This line can be amended some for better quality, performance, and add sound recording. Using the raw, lossless codecs for video and audio improves processor usage for better FPS recording:

ffmpeg -f x11grab -s wxga -i :0.0 -vcodec huffyuv -sameq -acodec pcm_s16le -f alsa -i pulse -ac 2 screencast.avi
  • -s and -i are for size and input. -s will give the dimensions and -i will define the co-ordinates. wxga is a definition of a video resolution standard (available ones are listed in man ffmpeg)
  • -r can be added to define the frame rate. Default is 25 and is good. Only reason really to change it is if frames are dropped during recording (marked with red).
  • -follow_mouse 100 can be added to follow mouse movements. 100 is the border in pixels that must be reached before the area is moved.

ffcast and FFmpeg

ffcast is a program that grabs and passes X.org server dimensions and co-rodinates to other programs. It has built-in support to pass these parameters for some programs including ffmpeg. So the command will now look like this:

ffcast -s ffmpeg -- -vcodec huffyuv -sameq -acodec pcm_s16le -f alsa -i pulse -ac 2 screencast.avi

ffcast’s -s option will prompt for the screen area and then pass the dimensions and co-orodinates to ffmpeg using --.

Now to make this easy, I put this in a bash script, it runs as such:

 screencast <a|f|m|w> - create screencasts (a)rea (f)ull-screen (m)ouse (w)indow

Here’s the bash script:

An example:

1 Comment

cVLC as Default Video Player



I love MPlayer. I’ve been using it for years. Whenever I needed to watch a video from my camera or downloaded something from YouTube it always did great. However, I revisited recently trying to play a DVD with MPlayer after having gone through a lengthy setup process a ways back and discovered MPlayer still cannot play DVD’s reliably. From the examples I tried it seemed as error-prone as before.

MPlayer always ran dependably and with almost no resources, videos would pop rightup. Learning to use the keyboard to navigate Mplayer was likely having one big remote control. However, I came to the decision that I cannot deal with the quirks of MPlayer anymore (there is good work on the mplayer2 project that is trying to fix a lot of the internal plumbing problems of MPlayer) but I needed something more-reliable. So when I decided just to use VLC, I accidentally learned about clvc.

I don’t normally use VLC because I use GNOME. Having MPlayer open up immediately was a big plus, but with clvc (which is part of the VLC package) videos open just like they did with MPlayer. And the playback quality is good. To play a DVD:

cvlc dvd://

The big thing is I’m going to have to learn all the key mappings again for cvlc, so a made a reference sheet:

Key Mappings

Desktop Recognition

To have clvc be recognized by the desktop a .desktop needs to be created:

and put in ~/.local/share/applications.

sudo update-desktop-database -q

Warning: I had to put it in /usr/share/applications/ for GNOME 3.6 to be able to recognize it in Default Applications and Removable media. This is likely a bug.

To have all known video types that VLC knows and define them to cVLC as the default application do:

xdg-mime default cvlc.desktop $(grep -oP 'video.*?;' /usr/share/applications/vlc.desktop | tr ';\n' ' ')

Load on DVD Insertion

I have yet to find out how to do this. This probably isn’t the correct way to do it, but it should work (note: my install is busted a bit right now so unable to test). Put in /usr/share/applications/clvc-dvd.desktop:)

[Desktop Entry]
Type=Application
Name=cVLC
GenericName=Media Player
GenericName[ca]=Reproductor multimèdia
GenericName[de]=Medienwiedergabe
GenericName[fr]=Lecteur multimédia
GenericName[it]=Lettore multimediale
GenericName[ja]=メディアプレーヤー
X-GNOME-FullName=Command Line VLC
Comment=Play movies and songs
Icon=vlc
TryExec=cvlc dvd://
Exec=cvlc dvd:// %U
Terminal=false
Type=Application
Categories=AudioVideo;Player;Recorder;
MimeType=video/dv;video/mpeg;video/x-mpeg;video/msvideo;video/quicktime;video/x-anim;video/x-avi;video/x-ms-asf;video/x-ms-wmv;video/x-msvideo;video/x-nsv;video/x-flc;video/x-fli;video/x-flv;video/vnd.rn-realvideo;video/mp4;video/mp4v-es;video/mp2t;application/ogg;application/x-ogg;video/x-ogm+ogg;audio/x-vorbis+ogg;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-wav;audio/x-mpegurl;audio/x-scpls;audio/x-m4a;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;application/vnd.rn-realmedia;audio/x-real-audio;audio/x-pn-realaudio;application/x-flac;audio/x-flac;application/x-shockwave-flash;misc/ultravox;audio/vnd.rn-realaudio;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;image/vnd.rn-realpix;audio/x-pn-realaudio-plugin;application/x-extension-mp4;audio/mp4;audio/amr;audio/amr-wb;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/xspf+xml;x-scheme-handler/mms;x-scheme-handler/rtmp;x-scheme-handler/rtsp;
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb
Keywords=Player;Capture;DVD;Audio;Video;Server;Broadcast;
NoDisplay=True

and then point to it in Removable Media > DVD.

YouTube videos

VLC has it’s own parser to be able to extract URL’s from YouTube so running is all that is needed to get the job done:

cvlc "http://www.youtube.com/..."
Leave a comment

Architectural Intent – a Wallpaper Tile



I tend to use my desktop as my workspace so I like wallpapers that act as more of a background decoration rather than elaborate artwork. So I created this. This is based on a wallpaper I found on the net (sorry, can’t remember where) and I re-did it. The original was in jpeg format and it had a bit of dithering to it.

It’s real basic, just 140×140, but I tile it and it comes out real nice:

It’s a vector image so it’s able to be resized real easy if need be.



1 Comment

systemd transfer… Done!



Well, after being throughly put off, I dived into systemd and have done a complete (pure) systemd installation; and I can tell you, I think its pretty nice.

I had no plans to change Arch’s initialization system, but I needed to switch to systemd because parts of GNOME 3 require it. Its been a long time a coming but systemd is a good thing for Linux, a real good thing. Arch’s init system was legendary. It’s what I believed what attracted a lot of people about Arch. Being so pulled to for me was it’s basic, straight-forward setup, so I wasn’t exactly excited about having to switch to systemd. systemd setup isn’t quite as easy as Arch’s rc system but I like it and found it has good logic. The best thing about systemd though will be its unification between other distros. This means that setting up a good number of programs will be similar no matter what distribution documentation is read. Also systemd will save a good amount of developers time as many of the distribution-based init scripts will no longer have to be specifically written (and will rather be included in the application). Plus it inclusion of D-BUS makes it a good deal more powerful.

Here’s what it looks like. It’s not quite as nice looking as Arch’s, but oh well:

systemd is the future… yeeeaaahh! A more unified Linux front.

A basic detail of my systemd install can be found on my GNOME 3 Setup page. Even better to read the whole page on the wiki which is really well done.

5 Comments

Disk and Memory Usage Scripts

At times I like to check my levels of disk and memory usage and it’s more convenient for me to do it from the command line. So, I created a couple scripts for them:

devtop 
 Filesystem      Size  Used Avail Use% Mounted on
 /dev/sda5       9.8G  6.4G  2.9G  69% /
 /dev/sda6       166G   38G  121G  24% /home
memtop 
 PROGRAM                   %MEM    #MEM
 firefox                   10.2    352.98 MB
 gnome-shell               4.1     141.76 MB
 Xorg                      1.5     53.60 MB
 nautilus                  1.2     41.52 MB
 gedit                     1.1     40.59 MB
 gnome-settings-           0.7     26.23 MB
 gnome-terminal            0.6     22.31 MB
 nm-applet                 0.6     21.30 MB
 python2                   0.6     20.89 MB

Saves me a lot of time over having to open a program :).

Leave a comment

Convert Videos to PSP



I’m a TED video junkie. I always have videos on my PSP ready to watch. I also like to put YouTube videos on there. I did this enough that I created a script for it that makes putting videos on my PSP real easy:

 pspvidconv <d*> <video(s)> - Convert videos to PSP (d to use directory)

The PSP allows use of a single-depth directory. The directory option (when using d flag) will ask if the user wants to create a new directory, if the answer is no, it will present the existing ones.

Warning: Currently h264 encoding isn’t working. The PSP will report that it is an unknown codec, so mp3g4-xvid is the only option with ffmpeg.

h264enc

Because I’ve found that options and settings change frequently with encoding tools, it is better to have an expert be able to handle them (otherwise, I will spend more time looking options up again). A good program to use is h264enc. It’s a shell script (perl, I believe) and well done; not good for many files as all settings will have to be re-entered but does a good job.

Handbrake

For Handbrake GUI I found this post. I have yet to find any handbrake-cli lines that work.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers