verzeichniss backup

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • verzeichniss backup

    hallo,

    zu allererst: ja ich hab gesucht -> suchergebnisse nicht wirklich hilfreich

    ich suche ein script oder ein shell befehl für linux mit der ich bestimmte verzeichnisse als zip oder gzip backupen kann.

    wer kann hilfreich zur seite stehen bei diesem gewagten manöver?

    danke fra7l7

  • #2
    tar cvvfz * > archiv.tar.gz

    zip -r archiv.zip *

    ...
    TBT

    Die zwei wichtigsten Regeln für eine berufliche Karriere:
    1. Verrate niemals alles was du weißt!


    PHP 2 AllPatrizier II Browsergame

    Kommentar


    • #3
      ich hab auf der rückseite die zeichnung nicht gefunden

      aber spoaß beiseite. packe ich das in ein shell wie system und wie bestimme ich das verzeichnis welches ich backupen will?

      danke dir sehr

      Kommentar


      • #4
        ja. das kommt in die shell.

        tar
        Code:
        GNU `tar' saves many files together into a single tape or disk archive, and
        can restore individual files from the archive.
        
        Usage: tar [OPTION]... [FILE]...
        
        Examples:
          tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
          tar -tvf archive.tar         # List all files in archive.tar verbosely.
          tar -xf archive.tar          # Extract all files from archive.tar.
        
        If a long option shows an argument as mandatory, then it is mandatory
        for the equivalent short option also.  Similarly for optional arguments.
        
        Main operation mode:
          -t, --list              list the contents of an archive
          -x, --extract, --get    extract files from an archive
          -c, --create            create a new archive
          -d, --diff, --compare   find differences between archive and file system
          -r, --append            append files to the end of an archive
          -u, --update            only append files newer than copy in archive
          -A, --catenate          append tar files to an archive
              --concatenate       same as -A
              --delete            delete from the archive (not on mag tapes!)
        
        Operation modifiers:
          -W, --verify               attempt to verify the archive after writing it
              --remove-files         remove files after adding them to the archive
          -k, --keep-old-files       don't replace existing files when extracting
              --overwrite            overwrite existing files when extracting
              --overwrite-dir        overwrite directory metadata when extracting
          -U, --unlink-first         remove each file prior to extracting over it
              --recursive-unlink     empty hierarchies prior to extracting directory
          -S, --sparse               handle sparse files efficiently
          -O, --to-stdout            extract files to standard output
          -G, --incremental          handle old GNU-format incremental backup
          -g, --listed-incremental=FILE
                                     handle new GNU-format incremental backup
              --ignore-failed-read   do not exit with nonzero on unreadable files
        
        Handling of file attributes:
              --owner=NAME             force NAME as owner for added files
              --group=NAME             force NAME as group for added files
              --mode=CHANGES           force (symbolic) mode CHANGES for added files
              --atime-preserve         don't change access times on dumped files
          -m, --modification-time      don't extract file modified time
              --same-owner             try extracting files with the same ownership
              --no-same-owner          extract files as yourself
              --numeric-owner          always use numbers for user/group names
          -p, --same-permissions       extract permissions information
              --no-same-permissions    do not extract permissions information
              --preserve-permissions   same as -p
          -s, --same-order             sort names to extract to match archive
              --preserve-order         same as -s
              --preserve               same as both -p and -s
        
        Device selection and switching:
          -f, --file=ARCHIVE             use archive file or device ARCHIVE
              --force-local              archive file is local even if has a colon
              --rsh-command=COMMAND      use remote COMMAND instead of rsh
          -[0-7][lmh]                    specify drive and density
          -M, --multi-volume             create/list/extract multi-volume archive
          -L, --tape-length=NUM          change tape after writing NUM x 1024 bytes
          -F, --info-script=FILE         run script at end of each tape (implies -M)
              --new-volume-script=FILE   same as -F FILE
              --volno-file=FILE          use/update the volume number in FILE
        
        Device blocking:
          -b, --blocking-factor=BLOCKS   BLOCKS x 512 bytes per record
              --record-size=SIZE         SIZE bytes per record, multiple of 512
          -i, --ignore-zeros             ignore zeroed blocks in archive (means EOF)
          -B, --read-full-records        reblock as we read (for 4.2BSD pipes)
        
        Archive format selection:
          -V, --label=NAME                   create archive with volume name NAME
                      PATTERN                at list/extract time, a globbing PATTERN
          -o, --old-archive, --portability   write a V7 format archive
              --posix                        write a POSIX format archive
          -j, --bzip2                        filter the archive through bzip2
          -z, --gzip, --ungzip               filter the archive through gzip
          -Z, --compress, --uncompress       filter the archive through compress
              --use-compress-program=PROG    filter through PROG (must accept -d)
        
        Local file selection:
          -C, --directory=DIR          change to directory DIR
          -T, --files-from=NAME        get names to extract or create from file NAME
              --null                   -T reads null-terminated names, disable -C
              --exclude=PATTERN        exclude files, given as a PATTERN
          -X, --exclude-from=FILE      exclude patterns listed in FILE
              --anchored               exclude patterns match file name start (default)
              --no-anchored            exclude patterns match after any /
              --ignore-case            exclusion ignores case
              --no-ignore-case         exclusion is case sensitive (default)
              --wildcards              exclude patterns use wildcards (default)
              --no-wildcards           exclude patterns are plain strings
              --wildcards-match-slash  exclude pattern wildcards match '/' (default)
              --no-wildcards-match-slash exclude pattern wildcards do not match '/'
          -P, --absolute-names         don't strip leading `/'s from file names
          -h, --dereference            dump instead the files symlinks point to
              --no-recursion           avoid descending automatically in directories
          -l, --one-file-system        stay in local file system when creating archive
          -K, --starting-file=NAME     begin at file NAME in the archive
          -N, --newer=DATE             only store files newer than DATE
              --newer-mtime=DATE       compare date and time when data changed only
              --after-date=DATE        same as -N
              --backup[=CONTROL]       backup before removal, choose version control
              --suffix=SUFFIX          backup before removal, override usual suffix
        
        Informative output:
              --help            print this help, then exit
              --version         print tar program version number, then exit
          -v, --verbose         verbosely list files processed
              --checkpoint      print directory names while reading the archive
              --totals          print total bytes written while creating archive
          -R, --block-number    show block number within archive with each message
          -w, --interactive     ask for confirmation for every action
              --confirmation    same as -w
        
        The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
        The version control may be set with --backup or VERSION_CONTROL, values are:
        
          t, numbered     make numbered backups
          nil, existing   numbered if numbered backups exist, simple otherwise
          never, simple   always make simple backups
        
        GNU tar cannot read nor produce `--posix' archives.  If POSIXLY_CORRECT
        is set in the environment, GNU extensions are disallowed with `--posix'.
        Support for POSIX is only partially implemented, don't count on it yet.
        ARCHIVE may be FILE, HOST:FILE or USER@HOST:FILE; DATE may be a textual date
        or a file name starting with `/' or `.', in which case the file's date is used.
        *This* `tar' defaults to `-f- -b20'.
        
        Report bugs to <bug-tar@gnu.org>.
        zip
        Code:
        Copyright (C) 1990-1999 Info-ZIP
        Type 'zip "-L"' for software license.
        Zip 2.3 (November 29th 1999). Usage:
        zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
          The default action is to add or replace zipfile entries from list, which
          can include the special name - to compress standard input.
          If zipfile and list are omitted, zip compresses stdin to stdout.
          -f   freshen: only changed files  -u   update: only changed or new files
          -d   delete entries in zipfile    -m   move into zipfile (delete files)
          -r   recurse into directories     -j   junk (don't record) directory names
          -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
          -1   compress faster              -9   compress better
          -q   quiet operation              -v   verbose operation/print version info
          -c   add one-line comments        -z   add zipfile comment
          -@   read names from stdin        -o   make zipfile as old as latest entry
          -x   exclude the following names  -i   include only the following names
          -F   fix zipfile (-FF try harder) -D   do not add directory entries
          -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
          -T   test zipfile integrity       -X   eXclude eXtra file attributes
          -y   store symbolic links as the link instead of the referenced file
          -R   PKZIP recursion (see manual)
          -e   encrypt                      -n   don't compress these suffixes
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Kommentar


        • #5
          evtl. auch http://www.php-resource.de/forum/sho...threadid=29710

          Kommentar


          • #6
            ne prima jetzt klappts es war ja gar nicht so schwer

            exec("zip -r archiv.zip /kunden/past-research.com/past/cms");

            goodie

            nächste task wäre ein möglickeit zubauen das backup jede woche lokal runterzuladen

            ich hab schon mal mit ftp_get probiert bin mir aber nicht sicher ob das gut ist? a) funktioniert es noch nicht b) wenn ich das als cronjob mache woher soll das script wissen wo es die datei lokal speichern soll

            was wäre die beste lösung?

            danke jungs, ihr seit spitze

            Kommentar


            • #7
              beide Rechner per timeserver syncronisieren.

              Als erstes auf dem Backuprechner per cron dies starten
              Code:
              nc -l -p 12345 > Backup.tar.gz
              eine Minute später auf dem Server
              Code:
              tar cvvfz * | nc zielhost 12345
              und schon landet das Backup vollautomatisch auf deinem
              Wunschrechner
              TBT

              Die zwei wichtigsten Regeln für eine berufliche Karriere:
              1. Verrate niemals alles was du weißt!


              PHP 2 AllPatrizier II Browsergame

              Kommentar


              • #8
                wenn ich
                PHP-Code:
                exec('zip -r 
                            '
                .$_SERVER['DOCUMENT_ROOT'].'/zipdata/archiv.zip 
                            '
                .$_SERVER['DOCUMENT_ROOT'].'/ordner
                    '
                ); 
                erhalte ich ein wunderbares zip mit allen dateien in allen unterordnern.
                nur möchte ich nicht den kompletten pfad im zip stehen haben,
                also statt:

                /web4711/html/sicherung/ordner/datei1.html
                /web4711/html/sicherung/ordner/keks/datei1.html
                /web4711/html/sicherung/ordner/keks/datei2.html
                /web4711/html/sicherung/ordner/keks/bisquit/datei1.html

                soll das archiv so aussehen:

                datei1.html
                /keks/datei1.html
                /keks/datei2.html
                /keks/bisquit/datei1.html

                gibts da eine spezielle option ?
                "-D" hat mich nicht weiter gebracht.
                Kissolino.com

                Kommentar


                • #9
                  und wie wär's mit chdir davor?

                  Kommentar


                  • #10
                    Original geschrieben von asp2php
                    und wie wär's mit chdir davor?
                    mir fehlt spontan die idee, wo ich das einsetzen sollte?
                    Kissolino.com

                    Kommentar


                    • #11
                      ich kenne mich nicht wirklich in linux aus, aber ich denke mit:
                      PHP-Code:
                      chdir($_SERVER['DOCUMENT_ROOT'].'/ordner');
                      exec('zip -r ./zipdata/archiv.zip ./*'); // oder ohne * : dontknow : 
                      könnte was werden oder

                      Kommentar


                      • #12
                        PHP-Code:
                        chdir($_SERVER['DOCUMENT_ROOT'].'/ordner');
                        exec('zip -r '.$_SERVER['DOCUMENT_ROOT'].'/zipdata/archiv.zip ./'); 
                        bingo ... chdir() ist die lösung.
                        thx
                        Kissolino.com

                        Kommentar

                        Lädt...
                        X