Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sysprog_spring25
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
louis.saulnier
sysprog_spring25
Commits
8f967bab
Commit
8f967bab
authored
1 month ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
added backup.sh
parent
4cca3c27
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cours/03-Scripting/backup.sh
+57
-0
57 additions, 0 deletions
Cours/03-Scripting/backup.sh
with
57 additions
and
0 deletions
Cours/03-Scripting/backup.sh
0 → 100755
+
57
−
0
View file @
8f967bab
#!/bin/bash
function
copy
{
echo
"Copie de
$1
"
cp
$1
$2
if
[
$?
-ne
0
]
;
then
echo
"Failed copying
$1
to
$2
"
>
&2
exit
5
fi
name
=
$(
basename
$1
)
f
=
$2
/
$name
chmod
440
$f
if
[
$?
-ne
0
]
;
then
echo
"Failed chaning
$f
permissions"
>
&2
exit
6
fi
}
if
[
$#
-ne
2
]
;
then
name
=
$(
basename
$0
)
echo
"Usage:
$name
src dest"
>
&2
echo
"src source directory containing txt and dat files"
>
&2
echo
"dst destination directory"
>
&2
exit
1
fi
if
[
!
-d
$1
]
;
then
echo
"source directory not found or not a directory!"
>
&2
exit
2
fi
DATA
=
$1
BACKUP
=
$2
# Si repertoire existe
if
[
-d
$BACKUP
]
;
then
# Efface les anciens backups
rm
-f
$BACKUP
/
*
if
[
$?
-ne
0
]
;
then
echo
"Failed removing files"
>
&2
exit
3
fi
else
# Cree repertoire
mkdir
-p
$BACKUP
if
[
$?
-ne
0
]
;
then
echo
"Failed creating
$BACKUP
directory"
>
&2
exit
4
fi
fi
# Backup les fichiers .txt et .dat
for
f
in
$DATA
/
*
.txt
$DATA
/
*
.dat
;
do
copy
$f
$BACKUP
# appel à la fonction
done
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment