Header Shadow Image


Simple Home Backup Solution

Earlier we've setup our HTPC and Backup and shared it out to our Windows machines, but one thing we did not add in is the backup job.  With the earlier solutions, the backup becomes trivial.  (Anything can become simple as long as the core design is well designed with future simplicity in mind.)  This is fairly simple by most system administrator standards but does assume you do know a bit of scripting to do the job with.  Naturally this can be done even easier so I'll show two options.  First the KSH option for automating this slightly:

 

#!/usr/bin/ksh

MOI=$(basename $0);

CDATE=$(date);

print — "$MOI: ($CDATE): Starting run of $MOI. " >> /var/log/$MOI.log 2>&1;

# TM="YES";
TM="NO";
TARGET="/mnt/HTPCBackupXFS";

for KEY in $( print \
                /mnt/FLASHLexarMedia-32GB-1             \
                /mnt/FLASHLexarMedia-32GB-0             \
                /mnt/FLASHKingstonCenton                \
                /mnt/VGEnt                              \
                /mnt/HTPCFileStorage                    \
        ); do
        [[ $TM == "NO" ]] && {
                print — "$MOI: Running rsync -avc –progress $KEY $TARGET:";
                rsync -avc –progress $KEY $TARGET;
        } || {
                print — "$MOI: Will run rsync -avc –progress $KEY $TARGET .";
        }
done >> /var/log/$MOI.log 2>&1;

Next we will edit the crontab to add in the job (Type crontab -e on the command line to edit the crontab file):

[root@mbpc-pc mnt]# crontab -l
30 0 * * * nice -n 19 /mnt/htpc.ksh
[root@mbpc-pc mnt]#

This will backup the other drives that I'm sharing to the RAID6 storage we've created.  Next we will take the key bits from there to create separate cron jobs in case scripting or KSH is not your thing.  This is just as good and may be quicker as it'll be ran in parallel (again type crontab -e to get in and edit the crontab file):

30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHLexarMedia-32GB-1 /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHLexarMedia-32GB-0 /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHKingstonCenton /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/VGEnt /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/HTPCFileStorage /mnt/HTPCBackupXFS;

Naturally, both methods work just as well and you may benefit from some parallelism here doing it the above way.  However, as more sources are managed, this may become more difficult to manage and more editing will be needed.  The above job schedules the backups to start 30 minutes past midnight, 0 and runs every day, *, every month, * each year, *, respectively from left to right.

Cheers,
TK

Schedule job on linux using at

[root@mbpc-pc mnt]# at now htpc.ksh
syntax error. Last token seen: h
Garbled time
[root@mbpc-pc mnt]# at now
at> /mnt/htpc.ksh
at>
job 12 at 2014-10-12 14:04
[root@mbpc-pc mnt]#
[root@mbpc-pc mnt]# ps -ef|grep -i htpc.ksh
root 26031 26030 0 14:04 ? 00:00:00 /usr/bin/ksh /mnt/htpc.ksh
root 26042 24646 0 14:04 pts/2 00:00:00 grep -i htpc.ksh
[root@mbpc-pc mnt]#

For reoccurring see cron.

Cheers,
TK

chcon: failed to change context of Operation not supported

Trying to change the sharing through selinux results in this:


[root@mbpc-pc mnt]# chcon -R -t samba_share_t /mnt/FLASHLexarMedia-32GB-1
chcon: failed to change context of `/mnt/FLASHLexarMedia-32GB-1' to `system_u:object_r:samba_share_t:s0': Operation not supported
[root@mbpc-pc mnt]#

[root@mbpc-pc mnt]# ls -lda –author -Z FLASHLexarMedia-32GB-1
drwx——. root root system_u:object_r:dosfs_t:s0     FLASHLexarMedia-32GB-1
[root@mbpc-pc mnt]#

[root@mbpc-pc mnt]# ls -lda –author -Z FLASHKingstonCenton
drwxrwxrwx. root root system_u:object_r:fusefs_t:s0    FLASHKingstonCenton
[root@mbpc-pc mnt]#

The issue is that you need to put the context line in the /etc/fstab mount command for NFS / VFAT like this:

[root@mbpc-pc mnt]# grep /mnt/FLASHKingstonCenton /etc/fstab
/dev/sdj1                                       /mnt/FLASHKingstonCenton        ntfs    context=system_u:object_r:samba_share_t:s0 0 2
[root@mbpc-pc mnt]#

[root@mbpc-pc mnt]# ls -lda –author -Z FLASHKingstonCenton
drwxrwxrwx. root root system_u:object_r:samba_share_t:s0 FLASHKingstonCenton
[root@mbpc-pc mnt]#

This should allow you to write/read to this volume from your windows network mounts.

Cheers,
TK

 

 

Keep last number of lines in a file

Here is a quick way to keep the last 5000 lines of a large file instead of entirely clearing it.  A little bit of AWK though a simple array and bob's your uncle:

root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
 1061 -rw-rw—-    1 daemon   mail         186022 Feb  1 00:20 test.txt
root [XYZ01] /var/spool/mail: cp -ip daemon test.txt
overwrite test.txt? y
root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1061 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 test.txt
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
root [XYZ01] /var/spool/mail: FILEN="test.txt"; tail -n 5000 $FILEN|awk 'BEGIN { FILEN="'"$FILEN"'"; } { ARY[CNT++]=”"$0; } END { for ( KEY in ARY ) { print ARY[KEY] > FILEN; } }'
root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
 1061 -rw-rw—-    1 daemon   mail         186022 Feb  1 00:21 test.txt
root [XYZ01] /var/spool/mail: wc -l test.txt
    5000 test.txt
root [XYZ01] /var/spool/mail:
root [XYZ01] /var/spool/mail:

 

Cheers,
Tom

Find / Detect IP conflicts

Here's a nifty way of figuring out if you have IP conflicts on a network ( yum search arp-scan ) :

[root@mbpc-pc ~]# arp-scan -I bond0 -l
Interface: bond0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9 with 512 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.0.1     f8:11:11:bc:47:8a       TP-LINK TECHNOLOGIES CO., LTD.
192.168.0.2     54:e6:fc:fb:ad:06       TP-LINK TECHNOLOGIES CO., LTD.
192.168.0.11    90:e6:b4:c6:7d:35       ASUSTek COMPUTER INC.
192.168.0.12    00:21:dc:cc:64:f4       Flextronics International
192.168.0.13    94:de:80:73:b1:78       GIGA-BYTE TECHNOLOGY CO.,LTD.
192.168.0.15    14:da:19:19:95:b5       ASUSTek COMPUTER INC.
192.168.0.10    28:5d:60:ca:44:1c       Azurewave Technologies, Inc.

8 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9: 512 hosts scanned in 3.460 seconds (147.98 hosts/sec). 7 responded
[root@mbpc-pc ~]#

Cheers,
Tom

Off Screen Windows: Recover by Resizing and Moving

Here are a few ways of recovering off screen windows by resizing and moving them.  This is particularly handy for folks that use multiple monitors then switch locations that have different configurations.  This table summarizes the options:

# Method
Keyboard ALT + TAB to Application

Then:

ALT + SPACE then M ( SHIFT + M ) then either use the arrow keys or move the mouse as it will ove the window since it will be attached to the application window at this point.

Mouse Right click on the app icon on the taskbar then click Move.  Your mouse should now be attached to the window.  Just move the mouse around to get your window back.  You can also use the arrow keys at this point to move the window as well.
Maximize option Right click on the app ion on the taskbar then click Maximize.  This should maximize in the current window.  Then left click and hold on the title bar to drag.
Windows Key Click the icon in the taskbar then hold down the Windows key and use the arrow keys to move the window back into view.

Cheers,
TK

Setup PS3 Controller With a Computer (PC) or Laptop

We've baught outselves four Intec PS3 controllers from The Source for about $3 each.  Yep, you read that right.  Just $3. Pulled up some old classic shooters that we haven't tried for some time but without a controller, they won't work.  Most controllers today, even the cheapest ones, are far better then the old ones from the Gravis Gamepad days.  The equivalent PS3  or PC Controllers are typically around $20 but in this case the deal was too good.  The question or not was whether this is going to work with a regular PC / Computer / Laptop.   It turns out that it can.

Read the rest of this entry »

Windows Explorer or Application does not show but starts in taskbar.

Here's what to do when the Windows Explorer does not show in the Taskbar.  We've tried to reboot and maximize and minimize but no luck.  In this case one only has to press SHIFT + LEFT CLICK on the taskbar then use the keyboard arrow keys to move the window back into the viewable screen.  

The alternative is the ALT + SPACE method but the menu will show up relative to the Windows Explorer window which if off the screen.  That won't be too helpful in this case.

And we're good!

Cheers,
TK

The Unix / Linux dd command: Generate, Create, Convert, Wipe and more

dd is a great unix and linux utility with many purposes and uses.  It is simply low level I/O that can ge used to generate files, convert files, wipe disks, recover disks and then some.  We've used dd quite extensively in our other posts to get work done and to recover data or disk metadata.  In this case we're looking to generate a large file in small chunks and wish to dig deeper into the inner workings of this command.  In this post we wish to demonstrate a couple of key features only.  We'll touch on a few of it's options.  We'll start with a simple file of 16 zeros:

# cat zero.txt
0000000000000000
#

Read the rest of this entry »

Configuring or Setting a Static IP on Samsung Ace 2X S7560M

Setting the Static IP on your Samsung Ace 2X S7560 has a very short solution:  can't be done from the GUI the device offers, OOTB.  The way to do this is to set a Static DHCP IP on the router.  Since we have DD-WRT on ours, the process is fairly straight forward though I had to part with my purely static IP configuration. The MAC filter as long as it's active does it's bit to limit WIFI connections as is.  The list is fairly straight forward to maintain.  

So what we'll implement here is Static DHCP IP Addresses through the Services tab of the DD-WRT.  

Read the rest of this entry »


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License