Dump contents of directory to samba share

Posted on 2004-11-24
Last Modified: 2013-12-15
Hi Folks,

I want to take the contents of various config (/etc) directories and regularly zip them up and copy to a remote samba location.

I'm looking for suggestions as to the most effective/efficient/eloquent script to acheive this.

It would also be neat if this script can issue an email alert to some remote address if there is any problem.

Assume that I am a ahell script novice but intermediate shell user.

Will award points to suggestions that help he write it myself, or double these points for writing it for me ;-)

Thanks in advance!

Question by:meverest
    LVL 17

    Accepted Solution

    First create a mountpoint for a samba share - mkdir /mnt/backup
    Then mount the samba share - mount -t smbfs //sambaserver/share /mnt/samba

    After that your script could be as simple as
    zip -d etcbackup /etc/*
    mv etc/backup /mnt/samba
    LVL 17

    Expert Comment

    should read mv etcbackup /mnt/samba
    LVL 37

    Author Comment


    that does the job.  for prosperity, this is the result:

    smbmount //myserver/backup$ /mountpoint -o username=myuser,password=mypass
    zip -r /etc/etcback /etc/*
    cp /etc/ /mountpoint /mypath/etcback_`date +"%d_%b_%Y_%H%M"`.zip
    umount /mountpoint

    does the job nicely, thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Problem with .htaccess file 4 47
    powershell backup 2 60
    NTP Server in VMware 5 88
    YII framework installation error 5 110
    I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now