Automatic Backup for Flash Drives on Linux

Anything is allowed, don't overdo the spam.
User avatar
Sajuuk
Nerd King of the Frozen North
Nerd King of the Frozen North
Posts: 3948
Joined: Fri Apr 28, 2006 2:23 am
Race: Shadow Creature/Progenitor/College Graduate/Nerd
Class: Geek 4/CodeMonkey 2/HardwareWiz 4/BasketballManager 4/WindowsAdmin 4/Root 2/ChaosIncarnate 1
Location: The depths of Baclora, where the Sajuuk lies...
Contact:

Automatic Backup for Flash Drives on Linux

Postby Sajuuk » Wed Nov 05, 2008 4:41 pm

Okay, so now that I have (theoretically) prevented another Data Loss instance for myself, I figured I would share the script I toiled for 15 minutes on that is used to prevent data loss. This should work on any linux system (still figuring out how to do it on windows automatically)

Step 1: install rsync (from shell: apt-get install rsync)
Step 2: put the following bash script somewhere convenient

Code: Select all

#/bin/bash
if mountpoint /media/E:
        then
                rsync -avz /media/E: /home/user/USBBackups
fi

Step 3: modify the bash script to your needs. "#/bin/bash" should be changed to whatever the path to Bash is on your computer (find out by running "which bash" in a shell). "/media/E:" should be changed to whatever the mountpoint for your drive is. "/home/user/USBBackups" should be changed to wherever you want the drive to backup to.
Step 4: find your crontab (usually at /etc/crontab)
Step 5: add the following line to your crontab with appropriate edits. Change "./home/user/backup.sh" to "./<wherever and whatever you called the script you made in step 2>". NOTE: you have to be root (or sudoed) to edit crontab.

Code: Select all

15,30,45,59 * * * * root ./home/user/backup.sh

Step 6: execute the following commands in a shell (preferably from /etc). I don't know if you need to be root or sudoed to execute them, but do so to be safe

Code: Select all

crontab -u <your username> /etc/crontab
crontab -u root /etc/crontab
crontab /etc/crontab

Step 7: restart the cron daemon using the following command

Code: Select all

sudo /etc/init.d/cron restart


this should execute that backup script every 15 minutes while the drive you want to backup is plugged in. hope this helps people prevent data loss.
[PCs Currently At - Sailing The High Seas]
TODAY: Arodus 28, 4711
PARTY BUFFS ACTIVE: None
SKULL AND SHACKLES COMBAT MAP
SKULL AND SHACKLES NPC RELATIONS DATABASE
SKULL AND SHACKLES PARTY LOOT/SUPPLIES

SHADOWRUN COMBAT MAP

IRON GODS PARTY LOOT/SUPPLIES

Stormreach Company Assets

"No matter how difficult or absurd you make a puzzle, your players will find an even more impossible and preposterous way of solving it." - http://www.shamusyoung.com/twentysidedtale/?p=680
Titles: He Whose Hand Shapes What Is, Epic Destroyer of Loot, Creator of the Elemental Plane of Bishoujos.

User avatar
Sajuuk
Nerd King of the Frozen North
Nerd King of the Frozen North
Posts: 3948
Joined: Fri Apr 28, 2006 2:23 am
Race: Shadow Creature/Progenitor/College Graduate/Nerd
Class: Geek 4/CodeMonkey 2/HardwareWiz 4/BasketballManager 4/WindowsAdmin 4/Root 2/ChaosIncarnate 1
Location: The depths of Baclora, where the Sajuuk lies...
Contact:

Re: Automatic Backup for Flash Drives on Linux

Postby Sajuuk » Wed Nov 05, 2008 5:06 pm

UPDATE: okay, it isn't working on my EEE right now. manually running crontab to try to install the new crontab. shall update again post-1215.
- codeMonkey Marty
[PCs Currently At - Sailing The High Seas]
TODAY: Arodus 28, 4711
PARTY BUFFS ACTIVE: None
SKULL AND SHACKLES COMBAT MAP
SKULL AND SHACKLES NPC RELATIONS DATABASE
SKULL AND SHACKLES PARTY LOOT/SUPPLIES

SHADOWRUN COMBAT MAP

IRON GODS PARTY LOOT/SUPPLIES

Stormreach Company Assets

"No matter how difficult or absurd you make a puzzle, your players will find an even more impossible and preposterous way of solving it." - http://www.shamusyoung.com/twentysidedtale/?p=680
Titles: He Whose Hand Shapes What Is, Epic Destroyer of Loot, Creator of the Elemental Plane of Bishoujos.

User avatar
Sajuuk
Nerd King of the Frozen North
Nerd King of the Frozen North
Posts: 3948
Joined: Fri Apr 28, 2006 2:23 am
Race: Shadow Creature/Progenitor/College Graduate/Nerd
Class: Geek 4/CodeMonkey 2/HardwareWiz 4/BasketballManager 4/WindowsAdmin 4/Root 2/ChaosIncarnate 1
Location: The depths of Baclora, where the Sajuuk lies...
Contact:

Re: Automatic Backup for Flash Drives on Linux

Postby Sajuuk » Wed Nov 05, 2008 5:21 pm

UPDATE: still nothing, but realized I forgot to install the new crontab and reboot the cron daemon. shall update again post-1230
[PCs Currently At - Sailing The High Seas]
TODAY: Arodus 28, 4711
PARTY BUFFS ACTIVE: None
SKULL AND SHACKLES COMBAT MAP
SKULL AND SHACKLES NPC RELATIONS DATABASE
SKULL AND SHACKLES PARTY LOOT/SUPPLIES

SHADOWRUN COMBAT MAP

IRON GODS PARTY LOOT/SUPPLIES

Stormreach Company Assets

"No matter how difficult or absurd you make a puzzle, your players will find an even more impossible and preposterous way of solving it." - http://www.shamusyoung.com/twentysidedtale/?p=680
Titles: He Whose Hand Shapes What Is, Epic Destroyer of Loot, Creator of the Elemental Plane of Bishoujos.


Return to “General Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests