FreeBSD und cp

allesdabei

allesdabei
Hi@All,

mich würde interessieren, wie ich ein "cp -rb /v1/etc/. /v2/etc" aus der Linux Welt, in FreeBSD umsetzen kann.

Zur Erklärung: Die Option -r ist für das Rekursive zuständig, die Option -b macht vorm überschreiben ein Backup der entsprechenden Datei.

Mir geht es genau um dieses Backup vor dem überschreiben. Die "man cp" gibt nichts her. Gibt es unter FreeBSD eine andere Lösung oder eine undokumentierte Option für cp?

Ich sage schon einmal Danke im voraus.

Grüße
 
Ob das FreeBSD cp eine versteckte Option hat weiß ich nicht, halte es aber für unwahrscheinlich. Als einfache quick & dirty Lösung würd ich einfach das GNU cp ( gcp ) aus den coreutils Package nehmen. Das sollte dann mit Linux halbwegs ident sein.
 
Das gcp aus den coreutils ist die Lösung.
kann eine Lösung sein ;)

Wegen solcher Unterschiede bin ich dazu übergegangen, quasi nur noch rsync zu nutzen.
rsync ist für mich einfach das bessere cp und dann noch weitgehend gleich zwischen unterschiedlichen Systemen und es geht auch über Netzwerk.
Es hat auch die Option -b für backups, die ich selbst aber noch nie genutzt habe.
Deshalb stelle ich hier mal einen Teil der man-page für FreeBSD ein, der vielleicht zeigen kann, weshalb ich das zur Sprache bringe:
Code:
       --backup, -b
              With this option, preexisting destination files are renamed as
              each file is transferred or deleted.  You can control where the
              backup file goes and what (if any) suffix gets appended using
              the --backup-dir and --suffix options.

              Note that if you don't specify --backup-dir, (1) the --omit-dir-
              times option will be forced on, and (2) if --delete is also in
              effect (without --delete-excluded), rsync will add a "protect"
              filter-rule for the backup suffix to the end of all your
              existing excludes (e.g. -f "P *~").  This will prevent
              previously backed-up files from being deleted.  Note that if you
              are supplying your own filter rules, you may need to manually
              insert your own exclude/protect rule somewhere higher up in the
              list so that it has a high enough priority to be effective
              (e.g., if your rules specify a trailing inclusion/exclusion of
              *, the auto-added rule would never be reached).

       --backup-dir=DIR
              This implies the --backup option, and tells rsync to store all
              backups in the specified directory on the receiving side.  This
              can be used for incremental backups.  You can additionally
              specify a backup suffix using the --suffix option (otherwise the
              files backed up in the specified directory will keep their
              original filenames).

              Note that if you specify a relative path, the backup directory
              will be relative to the destination directory, so you probably
              want to specify either an absolute path or a path that starts
              with "../".  If an rsync daemon is the receiver, the backup dir
              cannot go outside the module's path hierarchy, so take extra
              care not to delete it or copy into it.

       --suffix=SUFFIX
              This option allows you to override the default backup suffix
              used with the --backup (-b) option.  The default suffix is a ~
              if no --backup-dir was specified, otherwise it is an empty
              string.
 
Zurück
Oben